Add an "offscreen" mode that allows users to render studio to a texture

then uses SDL to blit the texture into the window.

PiperOrigin-RevId: 861697047
Change-Id: Ib949b4ade0c79d867ba74ce013bc2b6fa2571f56
This commit is contained in:
Haroon Qureshi
2026-01-27 06:47:22 -08:00
committed by Copybara-Service
parent dce2ed00ea
commit 669e9b7484
6 changed files with 242 additions and 39 deletions
+8 -1
View File
@@ -31,6 +31,7 @@
ABSL_FLAG(int, window_width, 1400, "Window width");
ABSL_FLAG(int, window_height, 720, "Window height");
ABSL_FLAG(std::string, model_file, "", "MuJoCo model file.");
ABSL_FLAG(bool, offscreen_mode, false, "Offscreen mode");
std::string Resolve(std::string_view path) {
std::string_view subpath = path.substr(path.find(':') + 1);
@@ -100,7 +101,13 @@ int main(int argc, char** argv, char** envp) {
const int width = absl::GetFlag(FLAGS_window_width);
const int height = absl::GetFlag(FLAGS_window_height);
mujoco::studio::App app(width, height, ini_path);
const bool offscreen_mode = absl::GetFlag(FLAGS_offscreen_mode);
mujoco::studio::App app({
.width = width,
.height = height,
.ini_path = ini_path,
.offscreen_mode = offscreen_mode,
});
// If the model file is not specified, try to load it from the first argument
std::string model_file = absl::GetFlag(FLAGS_model_file);