Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL ES 2.0 with osmesa

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?

like image 989
TheResistorNetwork Avatar asked May 08 '15 23:05

TheResistorNetwork


1 Answers

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!

like image 107
Greg Couch Avatar answered Oct 05 '22 12:10

Greg Couch