Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ Double-click on a geom and hold `Ctrl` to apply forces (right) and torques (left

Press `ESC` to quit.
Other key bindings are shown in the overlay menu (almost similar to `mujoco-py`).

# Optional Parameters

- `title`: set the title of the window, for example: `viewer = mujoco_viewer.MujocoViewer(model, data, title='My Demo')` (defaults to `mujoco-python-viewer`).
- `width`: set the window width, for example: `viewer = mujoco_viewer.MujocoViewer(model, data, width=300)` (defaults to full screen's width).
- `height`: set the window height, for example: `viewer = mujoco_viewer.MujocoViewer(model, data, height=300)` (defaults to full screen's height).
12 changes: 9 additions & 3 deletions mujoco_viewer/mujoco_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class MujocoViewer:
def __init__(self, model, data):
def __init__(self, model, data, title="mujoco-python-viewer", width=None, height=None):
self.model = model
self.data = data

Expand Down Expand Up @@ -39,9 +39,15 @@ def __init__(self, model, data):

# glfw init
glfw.init()
width, height = glfw.get_video_mode(glfw.get_primary_monitor()).size

if not width:
width, _ = glfw.get_video_mode(glfw.get_primary_monitor()).size

if not height:
_, height = glfw.get_video_mode(glfw.get_primary_monitor()).size

self.window = glfw.create_window(
width, height, "mujoco-python-viewer", None, None)
width, height, title, None, None)
glfw.make_context_current(self.window)
glfw.swap_interval(1)

Expand Down