class_docstr: Class for window rendering in all MuJoCo environments.
class_docstr_tok: ["Class","for","window","rendering","in","all","MuJoCo","environments","."]
code: def __init__(self, model, data):
      self._gui_lock = Lock()
      self._button_left_pressed = False
      self._button_right_pressed = False
      self._last_mouse_x = 0
      self._last_mouse_y = 0
      self._paused = False
      self._transparent = False
      self._contacts = False
      self._render_every_frame = True
      self._image_idx = 0
      self._image_path = "/tmp/frame_%07d.png"
      self._time_per_render = 1 / 60.0
      self._run_speed = 1.0
      self._loop_count = 0
      self._advance_by_one_step = False
      self._hide_menu = False
  
      # glfw init
      glfw.init()
      width, height = glfw.get_video_mode(
          glfw.get_primary_monitor()
      ).size
      self.window = glfw.create_window(
          width // 2, height // 2, "mujoco", None, None
      )
      glfw.make_context_current(self.window)
      glfw.swap_interval(1)
  
      framebuffer_width, framebuffer_height = glfw.get_framebuffer_size(
          self.window
      )
      window_width, _ = glfw.get_window_size(self.window)
      self._scale = framebuffer_width * 1.0 / window_width
  
      # set callbacks
      glfw.set_cursor_pos_callback(
          self.window, self._cursor_pos_callback
      )
      glfw.set_mouse_button_callback(
          self.window, self._mouse_button_callback
      )
      glfw.set_scroll_callback(self.window, self._scroll_callback)
      glfw.set_key_callback(self.window, self._key_callback)
  
      # get viewport
      self.viewport = mujoco.MjrRect(
          0, 0, framebuffer_width, framebuffer_height
      )
  
      super().__init__(model, data, offscreen=False)
  
imports: import collections
  import os
  import time
  from threading import Lock
  import glfw
  import imageio
  import mujoco
  import numpy
label_desc: Use image node_id 1 to create a new Viewer object from inherited base classes: RenderContext with example: obj = Viewer(model, data)