Skip to content

Commit 62ad92b

Browse files
JeanElsnersaran-t
authored andcommitted
dm_control: Import of refs/pull/315/head
PiperOrigin-RevId: 464986102 Change-Id: Ia5a5d56e244e9ab0502bed3f954a5638b405b672
2 parents 67dc335 + d37d13f commit 62ad92b

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

dm_control/viewer/gui/glfw_gui.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,21 @@ def event_loop(self, tick_func):
283283
tick_func: A callable, function to call every frame.
284284
"""
285285
while not glfw.window_should_close(self._context.window):
286-
pixels = tick_func()
287-
with self._context.make_current() as ctx:
288-
ctx.call(
289-
self._update_gui_on_render_thread, self._context.window, pixels)
290-
self._mouse.process_events()
291-
self._keyboard.process_events()
286+
self.update(tick_func)
287+
288+
def update(self, render_func):
289+
"""Updates the window and renders a new image.
290+
291+
Args:
292+
render_func: A callable returning a 3D numpy array of bytes (np.uint8),
293+
with dimensions (width, height, 3).
294+
"""
295+
pixels = render_func()
296+
with self._context.make_current() as ctx:
297+
ctx.call(
298+
self._update_gui_on_render_thread, self._context.window, pixels)
299+
self._mouse.process_events()
300+
self._keyboard.process_events()
292301

293302
def _update_gui_on_render_thread(self, window, pixels):
294303
self._fullscreen_quad.render(pixels, self.shape)

0 commit comments

Comments
 (0)