egl

eglInitialize failed with EGL_NOT_INITIALIZED


I am trying to run a 3D human model generator, where EGL is used. When I run the following code:

import OpenGL.EGL as egl
from ctypes import pointer

egl_display = egl.eglGetDisplay(egl.EGL_DEFAULT_DISPLAY)
print(egl_display)

major, minor = egl.EGLint(), egl.EGLint()
print(major, minor)

egl.eglInitialize(egl_display, pointer(major), pointer(minor))

the output of the above code is as follows:

#################### the first two print info ####################
<OpenGL._opaque.EGLDisplay_pointer object at 0x7f480e971940>
c_int(0) c_int(0)

#################### error ####################
Traceback (most recent call last):
  File "main.py", line 10, in <module>
    egl.eglInitialize(egl_display, pointer(major), pointer(minor))
  File "/data_HDD/zhuxingyu/anaconda3/envs/icon/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 415, in __call__
    return self( *args, **named )
  File "src/errorchecker.pyx", line 58, in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError
OpenGL.raw.EGL._errors.EGLError: EGLError(
        err = EGL_NOT_INITIALIZED,
        baseOperation = eglInitialize,
        cArguments = (
                <OpenGL._opaque.EGLDisplay_pointer object at 0x7f480e971940>,
                <OpenGL.raw.EGL._types.LP_c_int object at 0x7f480e971ac0>,
                <OpenGL.raw.EGL._types.LP_c_int object at 0x7f480e971b40>,
        ),
        result = 0
)

I'm unfamiliar to EGL and really confused about this error, and here's the information of my machine:

/usr/lib/x86_64-linux-gnu/libEGL_mesa.so.0
/usr/lib/x86_64-linux-gnu/libEGL_mesa.so.0.0.0
/usr/lib/x86_64-linux-gnu/libEGL_nvidia.so.0
/usr/lib/x86_64-linux-gnu/libEGL_nvidia.so.470.82.00
/usr/lib/x86_64-linux-gnu/libEGL.so
/usr/lib/x86_64-linux-gnu/libEGL.so.1
/usr/lib/x86_64-linux-gnu/libEGL.so.1.0.0

What else do I need to make eglInitialize run normally?


Solution

  • Solved by using docker image nvidia/cudagl@11.4.0-devel-ubuntu18.04