Implementation:Google deepmind Mujoco Platform Renderer
| Knowledge Sources | |
|---|---|
| Domains | Rendering, Backend Abstraction |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Provides a unified rendering abstraction that initializes and manages either the classic OpenGL or the Filament rendering backend for MuJoCo.
Description
renderer.cc implements the Renderer class which serves as a backend-agnostic rendering layer. At construction, it selects the appropriate backend based on compile-time defines: MUJOCO_RENDERER_CLASSIC_OPENGL uses EGL context creation and OpenGL ImGui integration, while the Filament path uses mjr_makeFilamentContext with graphics API selection (OpenGL, OpenGL headless, or Vulkan). The Init method creates the mjrContext and mjvScene, and Deinit frees these resources. The Filament configuration supports multiple API backends via MUJOCO_RENDERER_FILAMENT_OPENGL, MUJOCO_RENDERER_FILAMENT_VULKAN, etc.
Usage
Instantiated by Studio's App class with the native window handle. The renderer is reinitialized each time a new model is loaded, and destroyed on cleanup. It provides the mjrContext and mjvScene used by all subsequent rendering operations.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/experimental/platform/renderer.cc
- Lines: 1-224
Key Functions
Renderer::Renderer(void* native_window);
Renderer::~Renderer();
void Renderer::Init(const mjModel* model);
void Renderer::Deinit();
// Compile-time backend selection: MUJOCO_RENDERER_CLASSIC_OPENGL vs Filament
Import
#include "experimental/platform/renderer.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| native_window | void* | No | Native window handle (nullptr for offscreen/headless) |
| model | const mjModel* | Yes | MuJoCo model for context and scene initialization |
Outputs
| Name | Type | Description |
|---|---|---|
| render_context_ | mjrContext | Initialized rendering context (OpenGL or Filament) |
| scene_ | mjvScene | Allocated visualization scene with capacity for 2000 geoms |