(self, viewport, scene)
Renders the scene to the specified viewport.

    Args:
      viewport: Instance of Viewport.
      scene: Instance of MjvScene.
    Returns:
      A 3-dimensional array of shape (viewport.width, viewport.height, 3),
      with the contents of the front buffer.
Renders the scene to the specified viewport.
Renders the scene to the specified viewport .
def render(self, viewport, scene):
    """Renders the scene to the specified viewport.

    Args:
      viewport: Instance of Viewport.
      scene: Instance of MjvScene.
    Returns:
      A 3-dimensional array of shape (viewport.width, viewport.height, 3),
      with the contents of the front buffer.
    """
    if not np.array_equal(self._prev_viewport, viewport.dimensions):
      self._prev_viewport = viewport.dimensions
      if self._mujoco_context:
        self._mujoco_context.free()
      self._mujoco_context = None
    if not self._mujoco_context:
      # Ensure that MuJoCo's offscreen framebuffer is large enough to
      # accommodate the viewport.
      new_offwidth = max(self._model.vis.global_.offwidth, viewport.width)
      new_offheight = max(self._model.vis.global_.offheight, viewport.height)
      self._model.vis.global_.offwidth = new_offwidth
      self._model.vis.global_.offheight = new_offheight
      self._mujoco_context = wrapper.MjrContext(
          model=self._model,
          gl_context=self._surface,
          font_scale=enums.mjtFontScale.mjFONTSCALE_100)
      self._rgb_buffer = np.empty(
          (viewport.height, viewport.width, 3), dtype=np.uint8)

    with self._surface.make_current() as ctx:
      ctx.call(self._render_on_gl_thread, viewport, scene)
    self._pixels = np.flipud(self._rgb_buffer)
def render ( self , viewport , scene ) : if not np . array_equal ( self . _prev_viewport , viewport . dimensions ) : self . _prev_viewport = viewport . dimensions if self . _mujoco_context : self . _mujoco_context . free ( ) self . _mujoco_context = None if not self . _mujoco_context : # Ensure that MuJoCo's offscreen framebuffer is large enough to # accommodate the viewport. new_offwidth = max ( self . _model . vis . global_ . offwidth , viewport . width ) new_offheight = max ( self . _model . vis . global_ . offheight , viewport . height ) self . _model . vis . global_ . offwidth = new_offwidth self . _model . vis . global_ . offheight = new_offheight self . _mujoco_context = wrapper . MjrContext ( model = self . _model , gl_context = self . _surface , font_scale = enums . mjtFontScale . mjFONTSCALE_100 ) self . _rgb_buffer = np . empty ( ( viewport . height , viewport . width , 3 ) , dtype = np . uint8 ) with self . _surface . make_current ( ) as ctx : ctx . call ( self . _render_on_gl_thread , viewport , scene ) self . _pixels = np . flipud ( self . _rgb_buffer )