I am attempting to create an OpenGL context with osmesa (off-screen mesa). I wish to use the software implementation of mesa without a window and save the rendered output to a png file.
http://www.mesa3d.org/osmesa.html
I create a GL context with the following:
OSMesaContext context = OSMesaCreateContext(GL_RGBA, NULL);
OSMesaMakeCurrent(context, buffer, GL_UNSIGNED_BYTE, width, height);
However, when I invoke glGetString(GL_VERSION)
the version is 2.1 Mesa 10.1.1
. As expected, none of my GLSL ES shaders compile. When using SDL I can supply a version hint and create a GLES 2.0 context.
How do I specify the version of the GL context being created by osmesa?
If you look at src/mesa/drivers/osmesa/osmesa.c, around line 745, you can see that it explicitly asks for an OpenGL compatibility profile, which Mesa limits to OpenGL 2.1 and GLSL 130 (see src/mesa/main/version.c line . Replacing API_OPENGL_COMPAT with API_OPENGL_CORE results with the OpenGL version being 0.0 in Mesa 10.6.2, so unfortunately, the simple fix doesn't work. But, setting the MESA_GL_VERSION_OVERRIDE environment variable to "3.3" appears to work. Haven't tested beyond seeing what glGetString(GL_VERSION) returns. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With