Allow gl_context.GLContext to be None.

PiperOrigin-RevId: 625927487
Change-Id: I85d5658c8ea529716aaac12b17957c59319367cc
This commit is contained in:
Google DeepMind
2024-04-17 23:37:19 -07:00
committed by Copybara-Service
parent 4a76496533
commit d2392efe6c
+7 -2
View File
@@ -78,7 +78,10 @@ the clause:
# Create render contexts. # Create render contexts.
# TODO(nimrod): Figure out why pytype doesn't like gl_context.GLContext # TODO(nimrod): Figure out why pytype doesn't like gl_context.GLContext
self._gl_context = gl_context.GLContext(width, height) # type: ignore self._gl_context = None # type: ignore
if gl_context.GLContext is not None:
self._gl_context = gl_context.GLContext(width, height)
if self._gl_context:
self._gl_context.make_current() self._gl_context.make_current()
self._mjr_context = _render.MjrContext( self._mjr_context = _render.MjrContext(
model, _enums.mjtFontScale.mjFONTSCALE_150.value model, _enums.mjtFontScale.mjFONTSCALE_150.value
@@ -148,8 +151,10 @@ the clause:
self._scene.flags[_enums.mjtRndFlag.mjRND_SEGMENT] = True self._scene.flags[_enums.mjtRndFlag.mjRND_SEGMENT] = True
self._scene.flags[_enums.mjtRndFlag.mjRND_IDCOLOR] = True self._scene.flags[_enums.mjtRndFlag.mjRND_IDCOLOR] = True
if self._gl_context is None: if self._mjr_context is None:
raise RuntimeError('render cannot be called after close.') raise RuntimeError('render cannot be called after close.')
if self._gl_context:
self._gl_context.make_current() self._gl_context.make_current()
if self._depth_rendering: if self._depth_rendering: