From ca023a6f2855ab627f5f9a81e4ec011a3f6b1278 Mon Sep 17 00:00:00 2001 From: Nimrod Gileadi Date: Fri, 5 Jan 2024 06:49:51 -0800 Subject: [PATCH] Update EGL init code for Python 3.12. Fixes google-deepmind/mujoco#1299. PiperOrigin-RevId: 595982512 Change-Id: Ib0261483a7f6cb8addf04f5010f09d3554c8bf45 --- python/mujoco/egl/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/mujoco/egl/__init__.py b/python/mujoco/egl/__init__.py index d695ddc1..045b2aff 100644 --- a/python/mujoco/egl/__init__.py +++ b/python/mujoco/egl/__init__.py @@ -92,12 +92,13 @@ class GLContext: del max_width, max_height # unused num_configs = ctypes.c_long() config_size = 1 - config = EGL.EGLConfig() + # ctypes syntax for making an array of length config_size. + configs = (EGL.EGLConfig * config_size)() EGL.eglReleaseThread() EGL.eglChooseConfig( EGL_DISPLAY, EGL_ATTRIBUTES, - ctypes.byref(config), + configs, config_size, num_configs) if num_configs.value < 1: @@ -106,7 +107,7 @@ class GLContext: 'desired attributes: {}'.format(EGL_ATTRIBUTES)) EGL.eglBindAPI(EGL.EGL_OPENGL_API) self._context = EGL.eglCreateContext( - EGL_DISPLAY, config, EGL.EGL_NO_CONTEXT, None) + EGL_DISPLAY, configs[0], EGL.EGL_NO_CONTEXT, None) if not self._context: raise RuntimeError('Cannot create an EGL context.')