Skip to content

Could not create GL context #42

@ZireaelK

Description

@ZireaelK
  • System: WSL-kali/WSL-Ubuntu (Windows 10 22H2 19045.2965), Ubuntu 22.04
  • Docker Engine Version: 19.03.13
  • Docker Desktop Version: 20.10.24

When running python tool.py, the following error occurs:

#color_files=21000
model_path /tmp/0000000rgb.obj
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Traceback (most recent call last):
  File "tool.py", line 436, in <module>
    compute_per_ob_visibility()
  File "tool.py", line 275, in compute_per_ob_visibility
    compute_per_ob_visibility_worker(color_file,cfg)
  File "tool.py", line 251, in compute_per_ob_visibility_worker
    renderer = ModelRendererOffscreen([model_dir],K,H=cfg['H'],W=cfg['W'])
  File "/home/catgrasp/renderer.py", line 34, in __init__
    self.r = pyrender.OffscreenRenderer(self.W, self.H)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/offscreen.py", line 31, in __init__
    self._create()
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/offscreen.py", line 149, in _create
    self._platform.init_context()
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/platforms/pyglet_platform.py", line 52, in init_context
    width=1, height=1)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyglet/window/xlib/__init__.py", line 171, in __init__
    super(XlibWindow, self).__init__(*args, **kwargs)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyglet/window/__init__.py", line 615, in __init__
    context = config.create_context(gl.current_context)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyglet/gl/xlib.py", line 204, in create_context
    return XlibContextARB(self, share)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyglet/gl/xlib.py", line 314, in __init__
    super(XlibContext13, self).__init__(config, share)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyglet/gl/xlib.py", line 218, in __init__
    raise gl.ContextException('Could not create GL context')
pyglet.gl.ContextException: Could not create GL context

I use glxinfo | grep "OpenGL version" (by apt-get install mesa-utils) to get the version of OpenGL, and it returns OpenGL version string: 3.1 Mesa 20.0.8.

Then I run vim /opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/constants.py, changing

TARGET_OPEN_GL_MAJOR = 4
TARGET_OPEN_GL_MINOR = 1

with

TARGET_OPEN_GL_MAJOR = 3
TARGET_OPEN_GL_MINOR = 1

, and it came out a new error:

#color_files=21000
model_path /tmp/0000000rgb.obj
Traceback (most recent call last):
  File "tool.py", line 436, in <module>
    compute_per_ob_visibility()
  File "tool.py", line 275, in compute_per_ob_visibility
    compute_per_ob_visibility_worker(color_file,cfg)
  File "tool.py", line 260, in compute_per_ob_visibility_worker
    color,depth = renderer.render([ob_in_cam])
  File "/home/catgrasp/renderer.py", line 46, in render
    color, depth = self.r.render(self.scene)  # depth: float
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/offscreen.py", line 102, in render
    retval = self._renderer.render(scene, flags, seg_node_map)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/renderer.py", line 144, in render
    retval = self._forward_pass(scene, flags, seg_node_map=seg_node_map)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/renderer.py", line 326, in _forward_pass
    self._configure_forward_pass_viewport(flags)
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/renderer.py", line 1012, in _configure_forward_pass_viewport
    self._configure_main_framebuffer()
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/pyrender/renderer.py", line 1094, in _configure_main_framebuffer
    self.viewport_width, self.viewport_height
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/OpenGL/platform/baseplatform.py", line 402, in __call__
    return self( *args, **named )
  File "/opt/conda/envs/catgrasp/lib/python3.7/site-packages/OpenGL/error.py", line 232, in glCheckError
    baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
        err = 1282,
        description = b'invalid operation',
        baseOperation = glRenderbufferStorageMultisample,
        cArguments = (
                GL_RENDERBUFFER,
                4,
                GL_RGBA,
                2064,
                1544,
        )
)

The document of OpenGL(https://registry.khronos.org/OpenGL-Refpages/gl4/html/glRenderbufferStorageMultisample.xhtml) shows that

GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.
GL_INVALID_OPERATION is generated if internalformat is a signed or unsigned integer format and samples is greater than the value of GL_MAX_INTEGER_SAMPLES

, but i don't know what happened. I tried both WSL and Ubuntu 22.04, but they shared the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions