From bfa498cea73eebab27b3716d3ec25c1a7093ac48 Mon Sep 17 00:00:00 2001 From: ruziniuuuuu Date: Mon, 28 Apr 2025 12:26:11 +0800 Subject: [PATCH] add `CGLGLContext` for off-screen rendering on Darwin --- robosuite/renderers/context/cgl_context.py | 9 +++++++++ robosuite/utils/binding_utils.py | 2 ++ 2 files changed, 11 insertions(+) create mode 100644 robosuite/renderers/context/cgl_context.py diff --git a/robosuite/renderers/context/cgl_context.py b/robosuite/renderers/context/cgl_context.py new file mode 100644 index 0000000000..8a2ddfb289 --- /dev/null +++ b/robosuite/renderers/context/cgl_context.py @@ -0,0 +1,9 @@ +"""An OpenGL context created via CGL.""" + +from mujoco.cgl import GLContext + +class CGLGLContext(GLContext): + """An OpenGL context created via CGL.""" + + def __init__(self, max_width, max_height, device_id=0): + super().__init__(max_width, max_height) diff --git a/robosuite/utils/binding_utils.py b/robosuite/utils/binding_utils.py index ad09297f4a..5f9294faf2 100644 --- a/robosuite/utils/binding_utils.py +++ b/robosuite/utils/binding_utils.py @@ -69,6 +69,8 @@ def __init__(self, sim, offscreen=True, device_id=-1, max_width=640, max_height= from robosuite.renderers.context.osmesa_context import OSMesaGLContext as GLContext elif _SYSTEM == "Linux" and _MUJOCO_GL == "egl": from robosuite.renderers.context.egl_context import EGLGLContext as GLContext + elif _SYSTEM == "Darwin" and _MUJOCO_GL == "cgl": + from robosuite.renderers.context.cgl_context import CGLGLContext as GLContext else: from robosuite.renderers.context.glfw_context import GLFWGLContext as GLContext