Unable to get rendering to work on MacOS #2970
Replies: 1 comment 1 reply
-
|
Hi @davidhozic, The "OpenGL ARB_framebuffer_object required" error on MacOS is typically related to OpenGL context creation and compatibility. Here are some solutions: Quick Fixes1. Check OpenGL Version // When creating your GL context (e.g., with GLFW):
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);2. Ensure GL Context is Current // Make your window's GL context current
glfwMakeContextCurrent(window);
// Then initialize MuJoCo rendering
mjr_defaultContext(&con);
mjr_makeContext(m, &con, mjFONTSCALE_150);3. Load OpenGL Extensions // After creating GL context and making it current
glfwMakeContextCurrent(window);
// Load GL extensions (GLFW does this automatically)
// If not using GLFW, you might need GLEW or glad:
// glewInit(); // if using GLEWFor Rust SpecificallySince you're using Rust, make sure your GL context creation is correct. Here's an example with use glutin::prelude::*;
// Create GL context with proper version
let gl_config = /* your config */;
let context_attributes = ContextAttributesBuilder::new()
.with_context_api(ContextApi::OpenGl(Some(Version::new(3, 3))))
.with_profile(GlProfile::Core)
.build(Some(window.raw_window_handle()));
let gl_context = unsafe {
gl_config.display()
.create_context(&gl_config, &context_attributes)?
};
// Make context current
gl_context.make_current(&gl_surface)?;
// NOW call MuJoCo rendering functions
mjr_defaultContext(&mut con);
mjr_makeContext(model, &mut con, mjFONTSCALE_150);MacOS-Specific IssuesQEMU Emulation: If running x86 on ARM via QEMU, OpenGL support may be limited. QEMU's GL passthrough can be problematic. Try:
ARM Mac Native: Should work fine with proper GL context setup. Make sure you're using a recent version of your windowing library that supports Apple Silicon. Debugging Steps
const GLubyte* version = glGetString(GL_VERSION);
printf("OpenGL version: %s\n", version);
const GLubyte* extensions = glGetString(GL_EXTENSIONS);
// Check if "GL_ARB_framebuffer_object" is in the string
// Use MuJoCo's offscreen rendering which may be more forgiving
mjr_makeContext(m, &con, mjFONTSCALE_150);Working Example (C with GLFW)#include <GLFW/glfw3.h>
#include <mujoco/mujoco.h>
int main() {
// Initialize GLFW
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "MuJoCo", NULL, NULL);
glfwMakeContextCurrent(window);
// Load model
mjModel* m = mj_loadXML("model.xml", NULL, NULL, 0);
mjData* d = mj_makeData(m);
// Initialize rendering - should work now
mjrContext con;
mjr_defaultContext(&con);
mjr_makeContext(m, &con, mjFONTSCALE_150);
// Rendering loop...
return 0;
}If none of these work, please share:
Hope this helps! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Intro
Hi!
I am a researcher at University of Ljubljana.
My setup
MuJoCo 3.3.7, C API, both native ARM Mac Studio and QEMU emulation with x86. The QEMU OS version is 15.7.2, I'll add the Mac Studio version's when I'll have access to it again.
My question
I'm trying to run a program, written in C, to do some rendering. While everything works as expected on Windows and Linux platforms, I seem to be unable to do any rendering on MacOS.
Specifically, whenever I try to do rendering, I get the error:
Is there some environmental variable that I must set to make it work on MacOS? I haven't found any previous issues regarding this for MacOS specifically, so I assume it's something to do on my side.
Minimal model and/or code that explain my question
I'm technically using Rust, so I'll try to keep it general.
mujoco/src/render/render_context.c
Line 1543 in 96e3764
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions