Skip to content

Commit 60c32e1

Browse files
nimrod-gileadicopybara-github
authored andcommitted
Update EGL init code for Python 3.12.
Fixes google-deepmind/mujoco#1299. PiperOrigin-RevId: 595982512 Change-Id: I1824f5dd79b24d677772d69aca585ad36d08e2c2
1 parent 7a938bd commit 60c32e1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

dm_control/_render/pyopengl/egl_renderer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,13 @@ def _platform_init(self, unused_max_width, unused_max_height):
103103
"""Initialization this EGL context."""
104104
num_configs = ctypes.c_long(0)
105105
config_size = 1
106-
config = EGL.EGLConfig()
106+
# ctypes syntax for making an array of length config_size.
107+
configs = (EGL.EGLConfig * config_size)()
107108
EGL.eglReleaseThread()
108109
EGL.eglChooseConfig(
109110
EGL_DISPLAY,
110111
EGL_ATTRIBUTES,
111-
ctypes.byref(config),
112+
configs,
112113
config_size,
113114
num_configs)
114115
if num_configs.value < 1:
@@ -117,7 +118,7 @@ def _platform_init(self, unused_max_width, unused_max_height):
117118
'desired attributes: {}'.format(EGL_ATTRIBUTES))
118119
EGL.eglBindAPI(EGL.EGL_OPENGL_API)
119120
self._context = EGL.eglCreateContext(
120-
EGL_DISPLAY, config, EGL.EGL_NO_CONTEXT, None)
121+
EGL_DISPLAY, configs[0], EGL.EGL_NO_CONTEXT, None)
121122
if not self._context:
122123
raise RuntimeError('Cannot create an EGL context.')
123124

0 commit comments

Comments
 (0)