Skip to content

Commit 7c6085d

Browse files
committed
Add update method to GlfwWindow
1 parent 41d0c73 commit 7c6085d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

dm_control/viewer/gui/glfw_gui.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,20 @@ def event_loop(self, tick_func):
290290
self._mouse.process_events()
291291
self._keyboard.process_events()
292292

293+
def update(self, render_func):
294+
"""Updates the window and renders a new image.
295+
296+
Args:
297+
render_func: A callable returning a 3D numpy array of bytes (np.uint8),
298+
with dimensions (width, height, 3).
299+
"""
300+
pixels = render_func()
301+
with self._context.make_current() as ctx:
302+
ctx.call(
303+
self._update_gui_on_render_thread, self._context.window, pixels)
304+
self._mouse.process_events()
305+
self._keyboard.process_events()
306+
293307
def _update_gui_on_render_thread(self, window, pixels):
294308
self._fullscreen_quad.render(pixels, self.shape)
295309
glfw.swap_buffers(window)

0 commit comments

Comments
 (0)