[英]OpenGL EGL returns 0x300c (EGL_BAD_PARAMETER) at eglGetDisplay in docker
I am trying to run a simple example to set up EGL context in a docker container.我正在尝试运行一个简单的示例来在 docker 容器中设置 EGL 上下文。 However, I keep getting this error message:
但是,我不断收到此错误消息:
Detected 0 devices
terminate called after throwing an instance of 'std::runtime_error'
what(): EGL error 0x300c at eglGetDisplay
Aborted
Basically, eglQueryDevicesEXT
returns 0, and eglGetPlatformDisplayEXT
returns error code 0x300c (EGL_BAD_PARAMETER)
.基本上,
eglQueryDevicesEXT
返回 0,而eglGetPlatformDisplayEXT
返回错误代码0x300c (EGL_BAD_PARAMETER)
。
I have tried on:我试过:
On these docker environments, I installed openGL
and ELG
using apt-get install libgl1-mesa-dev
and apt-get install libegl1-mesa-dev
.在这些 docker 环境中,我使用
apt-get install libgl1-mesa-dev
和apt-get install libegl1-mesa-dev
安装了openGL
和ELG
。 CMake can find the components GL::GL
and EGL::EGL
. CMake 可以找到组件
GL::GL
和EGL::EGL
。
I have tried link to libEGL.so
both manually and using find_package
in CMake.我已经尝试手动链接到
libEGL.so
并在 CMake 中使用find_package
。
This is driving me crazy?这真让我抓狂? I can't figure out why EGL can't detect devices?
我不明白为什么 EGL 无法检测到设备? How can I resolve this error?
如何解决此错误?
Here is my full code.这是我的完整代码。 I have also tried
EGLDisplay eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
我也试过
EGLDisplay eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
which gives me the same error.这给了我同样的错误。 Thanks!
谢谢!
#include <EGL/egl.h>
#include <EGL/eglext.h>
void assertEGLError(const std::string& msg) {
EGLint error = eglGetError();
if (error != EGL_SUCCESS) {
std::stringstream s;
s << "EGL error 0x" << std::hex << error << " at " << msg;
throw std::runtime_error(s.str());
}
}
int main(int argc, char *argv[])
{
// 1. Initialize EGL
// EGLDisplay eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
int deviceID = 0; // TODO hardcode
EGLDisplay eglDpy;
EGLConfig config;
EGLContext context;
EGLint num_config;
static const int MAX_DEVICES = 16;
EGLDeviceEXT eglDevs[MAX_DEVICES];
EGLint numDevices;
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress("eglQueryDevicesEXT");
eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);
printf("Detected %d devices\n", numDevices);
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
// Choose device by deviceID
eglDpy = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, eglDevs[deviceID], nullptr);
assertEGLError("eglGetDisplay");
return 0;
}
OMG I finally solved this problem. OMG 我终于解决了这个问题。 Turned out I was linking to the wrong library on the server.
原来我链接到服务器上的错误库。
I found the answer in this post: https://forums.developer.nvidia.com/t/problem-with-opengl-visualization-without-an-x-server/73204/15我在这篇文章中找到了答案: https://forums.developer.nvidia.com/t/problem-with-opengl-visualization-without-an-x-server/73204/15
The key is to link to the libraries in /usr/lib/nvidia-410/
, not the system default /usr/local/lib/x86_64-linux-gnu/libEGL.so
关键是链接到
/usr/lib/nvidia-410/
中的库,而不是系统默认的/usr/local/lib/x86_64-linux-gnu/libEGL.so
The new CMake
that works:新的
CMake
有效:
target_link_libraries(sandbox PRIVATE /usr/lib/nvidia-410/libEGL.so)
target_link_libraries(sandbox PRIVATE /usr/lib/nvidia-410/libGLX.so)
target_link_libraries(sandbox PRIVATE /usr/lib/nvidia-410/libOpenGL.so)
Previously I used CMake's findOpenGL
to search for link libraries, which does not work之前我用CMake的
findOpenGL
搜索链接库,不起作用
find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL GLX)
include_directories(${OPENGL_INCLUDE_DIRS})
if(OPENGL_FOUND)
message("Found OpenGL in the current environment!")
else()
message("Error: No OpenGL found.")
endif()
message("OpenGL include dirs" )
message("${OPENGL_INCLUDE_DIR}")
message("EGL include dirs" )
message("${OPENGL_EGL_INCLUDE_DIRS}")
if (OpenGL_EGL_FOUND)
message("EGL Found!")
else()
message("EGL Not Found!")
endif()
message(${OPENGL_egl_LIBRARY})
message(${OPENGL_glx_LIBRARY})
message(${OPENGL_opengl_LIBRARY}
Note again this does not work !!再次注意这不起作用!
/usr/local/lib/x86_64-linux-gnu/libEGL.so
/usr/local/lib/x86_64-linux-gnu/libGLX.so
/usr/local/lib/x86_64-linux-gnu/libOpenGL.so
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.