Hello,<br><br>I've downloaded the latest 7.10.3 and I need to be able to dynamically load OSMesa. Is this possible? I've tried to use dlopen and dlsym to load the functions and all the OSMesa calls return success but when I make the gl calls I get:<br>
<br>GL User Error: glGetIntegerv called without a rendering context<br>GL User Error: glGetIntegerv called without a rendering context<br>GL User Error: glGetIntegerv called without a rendering context<br><br>Any help would be appreciated. <br>
<br>Thanks,<br>Paul<br><br>My sample program is as follows. I compile it with the same flags as the rest of the demo programs without linking to OSMesa.<br><br>static void *<br>loadOSMesa()<br>{<br> return dlopen("libOSMesa.so", RTLD_DEEPBIND | RTLD_NOW | RTLD_GLOBAL); <br>
}<br><br>static OSMesaContext<br>dynOSMesaCreateContext()<br>{<br> typedef OSMesaContext (*CreateContextProto)( GLenum , GLint , GLint , GLint , OSMesaContext );<br> static void *createPfunc = NULL;<br> CreateContextProto createContext;<br>
if (createPfunc == NULL)<br> {<br> void *handle = loadOSMesa();<br> if (handle)<br> {<br> createPfunc = dlsym(handle, "OSMesaCreateContextExt");<br> }<br> }<br><br> if (createPfunc)<br> {<br>
createContext = (CreateContextProto)(createPfunc);<br> return (*createContext)(GL_RGBA, 16, 0, 0, NULL);<br> }<br> return 0;<br>}<br><br>static GLboolean <br>dynOSMesaMakeCurrent(OSMesaContext cid, void * win, GLenum type, GLsizei w, GLsizei h)<br>
{<br> typedef GLboolean (*MakeCurrentProto)(OSMesaContext, void *, GLenum, GLsizei, GLsizei);<br> static void *currentPfunc = NULL;<br> MakeCurrentProto makeCurrent;<br> if (currentPfunc == NULL)<br> {<br> void *handle = loadOSMesa();<br>
if (handle)<br> {<br> currentPfunc = dlsym(handle, "OSMesaMakeCurrent");<br> }<br> }<br> if (currentPfunc)<br> {<br> makeCurrent = (MakeCurrentProto)(currentPfunc);<br> return (*makeCurrent)(cid, win, type, w, h);<br>
}<br> return GL_FALSE;<br>}<br><br>int<br>main(int argc, char *argv[])<br>{<br> OSMesaContext ctx;<br> void *buffer;<br><br> ctx = dynOSMesaCreateContext();<br> if (!ctx) {<br> printf("OSMesaCreateContext failed!\n");<br>
return 0;<br> }<br><br> int Width = 100;<br> int Height = 100;<br> <br> /* Allocate the image buffer */<br> buffer = malloc( Width * Height * 4 * sizeof(GLubyte) );<br> if (!buffer) {<br> printf("Alloc image buffer failed!\n");<br>
return 0;<br> }<br><br> /* Bind the buffer to the context and make it current */<br> if (!dynOSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, Width, Height )) {<br> printf("OSMesaMakeCurrent failed!\n");<br>
return 0;<br> }<br> <br><br> {<br> int z, s, a;<br> glGetIntegerv(GL_DEPTH_BITS, &z);<br> glGetIntegerv(GL_STENCIL_BITS, &s);<br> glGetIntegerv(GL_ACCUM_RED_BITS, &a);<br> printf("Depth=%d Stencil=%d Accum=%d\n", z, s, a);<br>
}<br><br> return 0;<br>}<br><br>