Skip to content

Commit 276c6e8

Browse files
committed
Make GLFW the default rendering backend
Defaulting to EGL means that the viewer won't work unless the `MUJOCO_GL` environment variable is set to `glfw` (#78). I have also updated the README to make this a bit clearer. PiperOrigin-RevId: 235502880
1 parent 2132a02 commit 276c6e8

2 files changed

Lines changed: 47 additions & 39 deletions

File tree

README.md

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,29 @@
44

55
This package contains:
66

7-
- [`dm_control.mjcf`](dm_control/mjcf/README.md): A library for composing and modifying
8-
MuJoCo MJCF models in Python.
7+
- [`dm_control.mjcf`]: A library for composing and modifying MuJoCo MJCF
8+
models in Python.
99

10-
- [`dm_control.mujoco`](dm_control/mujoco/README.md): Libraries that provide Python
11-
bindings to the MuJoCo physics engine.
10+
- [`dm_control.mujoco`]: Libraries that provide Python bindings to the MuJoCo
11+
physics engine.
1212

13-
- [`dm_control.suite`](dm_control/suite/README.md): A set of Python Reinforcement
14-
Learning environments powered by the MuJoCo physics engine.
13+
- [`dm_control.suite`]: A set of Python Reinforcement Learning environments
14+
powered by the MuJoCo physics engine.
1515

16-
- [`dm_control.viewer`](dm_control/viewer/README.md): An interactive environment viewer.
16+
- [`dm_control.viewer`]: An interactive environment viewer.
1717

18-
If you use this package, please cite our accompanying
19-
[tech report](https://arxiv.org/abs/1801.00690).
18+
If you use this package, please cite our accompanying [tech report].
2019

2120
## Installation and requirements
2221

2322
Follow these steps to install `dm_control`:
2423

25-
1. Download MuJoCo Pro 2.00 from the download page on the
26-
[MuJoCo website](http://www.mujoco.org/). MuJoCo Pro must be installed
27-
before `dm_control`, since `dm_control`'s install script generates Python
28-
[`ctypes`](https://docs.python.org/2/library/ctypes.html) bindings based on
29-
MuJoCo's header files. By default, `dm_control` assumes that the MuJoCo Zip
30-
archive is extracted as `~/.mujoco/mujoco200_$PLATFORM` where `$PLATFORM` is
31-
either `linux`, `win64`, or `macos`.
24+
1. Download MuJoCo Pro 2.00 from the download page on the [MuJoCo website].
25+
MuJoCo Pro must be installed before `dm_control`, since `dm_control`'s
26+
install script generates Python [`ctypes`] bindings based on MuJoCo's header
27+
files. By default, `dm_control` assumes that the MuJoCo Zip archive is
28+
extracted as `~/.mujoco/mujoco200_$PLATFORM` where `$PLATFORM` is either
29+
`linux`, `win64`, or `macos`.
3230

3331
2. Install the `dm_control` Python package by running `pip install
3432
git+git://github.com/deepmind/dm_control.git` (PyPI package coming soon) or
@@ -40,40 +38,40 @@ Follow these steps to install `dm_control`:
4038
with the `headers-dir` command line argument.
4139

4240
3. Install a license key for MuJoCo, required by `dm_control` at runtime. See
43-
the [MuJoCo license key page](https://www.roboti.us/license.html) for
44-
further details. By default, `dm_control` looks for the MuJoCo license key
45-
file at `~/.mujoco/mjkey.txt`.
41+
the [MuJoCo license key page] for further details. By default, `dm_control`
42+
looks for the MuJoCo license key file at `~/.mujoco/mjkey.txt`.
4643

4744
4. If the license key (e.g. `mjkey.txt`) or the shared library provided by
4845
MuJoCo Pro (e.g. `libmujoco200.so` or `libmujoco200.dylib`) are installed at
4946
non-default paths, specify their locations using the `MJKEY_PATH` and
5047
`MJLIB_PATH` environment variables respectively.
5148

52-
## Additional instructions for Linux
49+
## Rendering
5350

5451
The MuJoCo Python bindings support three different OpenGL rendering backends:
55-
EGL (headless, hardware-accelerated), GLFW (windowed, hardware-accelerated),
56-
and OSMesa (purely software-based). At least one of these three backends
57-
must be available in order render through `dm_control`.
52+
EGL (headless, hardware-accelerated), GLFW (windowed, hardware-accelerated), and
53+
OSMesa (purely software-based). At least one of these three backends must be
54+
available in order render through `dm_control`.
5855

59-
* "Headless" hardware rendering (i.e. without a windowing system such as X11)
60-
requires [EXT_platform_device](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_device.txt)
61-
support in the EGL driver. Recent Nvidia drivers support this. You will also
62-
need GLEW. On Debian and Ubuntu, this can be installed via
63-
`sudo apt-get install libglew2.0`.
56+
* Hardware rendering with a windowing system is supported via GLFW and GLEW.
57+
On Linux these can be installed using your distribution's package manager.
58+
For example, on Debian and Ubuntu, this can be done by running `sudo apt-get
59+
install libglfw3 libglew2.0`. Please note that:
60+
61+
- [`dm_control.viewer`] can only be used with GLFW.
62+
- GLFW will not work on headless machines.
6463

65-
* Hardware rendering with a windowing system is also supported via GLFW and
66-
GLEW, which can be installed via your Linux distribution's package manager.
67-
For example, on Debian and Ubuntu, this can be done by running
68-
`sudo apt-get install libglfw3 libglew2.0`.
64+
* "Headless" hardware rendering (i.e. without a windowing system such as X11)
65+
requires [EXT_platform_device] support in the EGL driver. Recent Nvidia
66+
drivers support this. You will also need GLEW. On Debian and Ubuntu, this
67+
can be installed via `sudo apt-get install libglew2.0`.
6968

7069
* Software rendering requires GLX and OSMesa. On Debian and Ubuntu these can
7170
be installed using `sudo apt-get install libgl1-mesa-glx libosmesa6`.
7271

73-
By default, `dm_control` will attempt to use EGL first, then GLFW, then OSMesa.
74-
You can also specify a particular backend to use by setting the
75-
`MUJOCO_GL=` environment variable to `"egl"`, `"glfw"`, or `"osmesa"`,
76-
respectively.
72+
By default, `dm_control` will attempt to use GLFW first, then EGL, then OSMesa.
73+
You can also specify a particular backend to use by setting the `MUJOCO_GL=`
74+
environment variable to `"glfw"`, `"egl"`, or `"osmesa"`, respectively.
7775

7876
## Additional instructions for Homebrew users on macOS
7977

@@ -84,3 +82,13 @@ respectively.
8482
2. Before running, the `DYLD_LIBRARY_PATH` environment variable needs to be
8583
updated with the path to the GLFW library. This can be done by running
8684
`export DYLD_LIBRARY_PATH=$(brew --prefix)/lib:$DYLD_LIBRARY_PATH`.
85+
86+
[EXT_platform_device]: https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_device.txt
87+
[MuJoCo license key page]: https://www.roboti.us/license.html
88+
[MuJoCo website]: http://www.mujoco.org/
89+
[tech report]: https://arxiv.org/abs/1801.00690
90+
[`ctypes`]: https://docs.python.org/2/library/ctypes.html
91+
[`dm_control.mjcf`]: dm_control/mjcf/README.md
92+
[`dm_control.mujoco`]: dm_control/mujoco/README.md
93+
[`dm_control.suite`]: dm_control/suite/README.md
94+
[`dm_control.viewer`]: dm_control/viewer/README.md

dm_control/_render/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"""OpenGL context management for rendering MuJoCo scenes.
1717
1818
By default, the `Renderer` class will try to load one of the following rendering
19-
APIs, in descending order of priority: EGL > GLFW > OSMesa.
19+
APIs, in descending order of priority: GLFW > EGL > OSMesa.
2020
2121
It is also possible to select a specific backend by setting the `MUJOCO_GL=`
22-
environment variable to 'egl', 'glfw' or 'osmesa'.
22+
environment variable to 'glfw', 'egl', or 'osmesa'.
2323
"""
2424

2525
import collections
@@ -47,8 +47,8 @@ def _import_osmesa():
4747
# pylint: enable=g-import-not-at-top
4848

4949
_ALL_RENDERERS = collections.OrderedDict([
50-
(constants.EGL, _import_egl),
5150
(constants.GLFW, _import_glfw),
51+
(constants.EGL, _import_egl),
5252
(constants.OSMESA, _import_osmesa),
5353
])
5454

0 commit comments

Comments
 (0)