Implementation:Google deepmind Mujoco Platform Window
| Knowledge Sources | |
|---|---|
| Domains | Windowing, Platform Integration |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Manages the SDL2 window lifecycle, ImGui initialization, font loading, and platform-specific native window handle extraction for MuJoCo applications.
Description
window.cc implements the platform Window class which wraps SDL2 for cross-platform windowing. The InitImGui function creates the ImGui context, configures docking, DPI scaling, and font loading from embedded resources (OpenSans-Regular.ttf and FontAwesome via mju_openResource). Font configuration supports both the main text font and icon font merging with appropriate glyph ranges. The file handles platform-specific native window handle extraction (with a macOS extern for GetNativeWindowOsx) and includes a workaround for X11/Xlib's Status macro conflicting with C++ code.
Usage
Instantiated at application startup to create the main window. The window provides the native handle needed by the renderer, processes SDL2 events, and hosts the ImGui integration layer. It is the foundation for all visual output in Studio and similar applications.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/experimental/platform/window.cc
- Lines: 1-285
Key Functions
static void InitImGui(SDL_Window* window, float content_scale, bool load_fonts, bool build_fonts);
// ImGui context creation with docking, DPI scaling
// Font loading: OpenSans-Regular.ttf (main), FontAwesome (icons, merged)
// Platform-specific native window handle extraction
Import
#include "experimental/platform/window.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| window | SDL_Window* | Yes | SDL2 window for ImGui initialization |
| content_scale | float | Yes | DPI content scale factor |
| load_fonts | bool | Yes | Whether to load embedded fonts |
| build_fonts | bool | Yes | Whether to build the font atlas |
Outputs
| Name | Type | Description |
|---|---|---|
| ImGui context | ImGuiContext* | Initialized ImGui context with fonts, docking, and SDL2 backend |
| Native handle | void* | Platform-specific native window handle for renderer |