Use runtime enum for the renderer backend instead of preprocessor macros.

TESTED:
  studio:vulkan
  studio:vulkan --offscreen_mode=true
  studio:opengl
  studio:opengl_egl
  studio:classic
  studio:classic --offscreen_mode=true
  studio:server
  robot_sim/frontend:debug_server
  pyviewer:example
  pyviewer:example --define=mujoco_gl=vulkan
PiperOrigin-RevId: 864768322
Change-Id: I4478e0115b3807060d60d98b4ddfd63da9389aac
This commit is contained in:
Haroon Qureshi
2026-02-03 02:12:40 -08:00
committed by Copybara-Service
parent 24e5b966c3
commit 1a2bca4986
7 changed files with 136 additions and 55 deletions
+3 -9
View File
@@ -20,6 +20,8 @@
#include <string>
#include <string_view>
#include "experimental/platform/renderer_backend.h"
#if __has_include("third_party/GL/gl/include/EGL/egl.h")
#define MUJOCO_STUDIO_EGL_SUPPORTED 1
#include "third_party/GL/gl/include/EGL/egl.h"
@@ -35,16 +37,8 @@ namespace mujoco::platform {
// handles events from the window.
class Window {
public:
// Configures the window for the specified rendering backend.
enum RenderConfig {
kClassicOpenGL,
kFilamentVulkan,
kFilamentOpenGL,
kFilamentWebGL,
};
struct Config {
RenderConfig render_config = kClassicOpenGL;
RendererBackend renderer_backend = RendererBackend::ClassicOpenGl;
bool enable_keyboard = true;
bool load_fonts = true;
bool offscreen_mode = false;