Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyglet.gl.ContextException: Could not create GL context #42

Closed
AmoghTiwari opened this issue Mar 27, 2023 · 1 comment
Closed

pyglet.gl.ContextException: Could not create GL context #42

AmoghTiwari opened this issue Mar 27, 2023 · 1 comment

Comments

@AmoghTiwari
Copy link

Traceback (most recent call last):
File "humor/fitting/viz_fitting_rgb.py", line 467, in
main(args)
File "humor/fitting/viz_fitting_rgb.py", line 342, in main
img_extn=IM_EXTN)
File "/data/amogh/tcs_related/humor/humor/fitting/../viz/utils.py", line 182, in viz_smpl_seq
default_cam_rot=cam_rot)
File "/data/amogh/tcs_related/humor/humor/fitting/../viz/mesh_viewer.py", line 108, in init
self.viewer = pyrender.OffscreenRenderer(*self.figsize, point_size=2.75)
File "/data/groot/miniconda3/envs/humor_env/lib/python3.7/site-packages/pyrender/offscreen.py", line 31, in init
self._create()
File "/data/groot/miniconda3/envs/humor_env/lib/python3.7/site-packages/pyrender/offscreen.py", line 149, in _create
self._platform.init_context()
File "/data/groot/miniconda3/envs/humor_env/lib/python3.7/site-packages/pyrender/platforms/pyglet_platform.py", line 52, in init_context
width=1, height=1)
File "/data/groot/miniconda3/envs/humor_env/lib/python3.7/site-packages/pyglet/window/xlib/init.py", line 173, in init
super(XlibWindow, self).init(*args, **kwargs)
File "/data/groot/miniconda3/envs/humor_env/lib/python3.7/site-packages/pyglet/window/init.py", line 606, in init
context = config.create_context(gl.current_context)
File "/data/groot/miniconda3/envs/humor_env/lib/python3.7/site-packages/pyglet/gl/xlib.py", line 204, in create_context
return XlibContextARB(self, share)
File "/data/groot/miniconda3/envs/humor_env/lib/python3.7/site-packages/pyglet/gl/xlib.py", line 314, in init
super(XlibContext13, self).init(config, share)
File "/data/groot/miniconda3/envs/humor_env/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

@AmoghTiwari
Copy link
Author

AmoghTiwari commented Mar 27, 2023

I was able to solve this by placing the below-mentioned line in the humor/viz/mesh_viewer.py file, AFTER the import os line

os.environ['PYOPENGL_PLATFORM'] = 'egl'

This issue is related to offscreen rendering. See https://pyrender.readthedocs.io/en/latest/examples/offscreen.html for details.

Issue #15 also discusses the same problem and suggests an alternate way to resolve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant