Hello, 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:
GL User Error: glGetIntegerv called without a rendering context GL User Error: glGetIntegerv called without a rendering context GL User Error: glGetIntegerv called without a rendering context Any help would be appreciated. Thanks, Paul My sample program is as follows. I compile it with the same flags as the rest of the demo programs without linking to OSMesa. static void * loadOSMesa() { return dlopen("libOSMesa.so", RTLD_DEEPBIND | RTLD_NOW | RTLD_GLOBAL); } static OSMesaContext dynOSMesaCreateContext() { typedef OSMesaContext (*CreateContextProto)( GLenum , GLint , GLint , GLint , OSMesaContext ); static void *createPfunc = NULL; CreateContextProto createContext; if (createPfunc == NULL) { void *handle = loadOSMesa(); if (handle) { createPfunc = dlsym(handle, "OSMesaCreateContextExt"); } } if (createPfunc) { createContext = (CreateContextProto)(createPfunc); return (*createContext)(GL_RGBA, 16, 0, 0, NULL); } return 0; } static GLboolean dynOSMesaMakeCurrent(OSMesaContext cid, void * win, GLenum type, GLsizei w, GLsizei h) { typedef GLboolean (*MakeCurrentProto)(OSMesaContext, void *, GLenum, GLsizei, GLsizei); static void *currentPfunc = NULL; MakeCurrentProto makeCurrent; if (currentPfunc == NULL) { void *handle = loadOSMesa(); if (handle) { currentPfunc = dlsym(handle, "OSMesaMakeCurrent"); } } if (currentPfunc) { makeCurrent = (MakeCurrentProto)(currentPfunc); return (*makeCurrent)(cid, win, type, w, h); } return GL_FALSE; } int main(int argc, char *argv[]) { OSMesaContext ctx; void *buffer; ctx = dynOSMesaCreateContext(); if (!ctx) { printf("OSMesaCreateContext failed!\n"); return 0; } int Width = 100; int Height = 100; /* Allocate the image buffer */ buffer = malloc( Width * Height * 4 * sizeof(GLubyte) ); if (!buffer) { printf("Alloc image buffer failed!\n"); return 0; } /* Bind the buffer to the context and make it current */ if (!dynOSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, Width, Height )) { printf("OSMesaMakeCurrent failed!\n"); return 0; } { int z, s, a; glGetIntegerv(GL_DEPTH_BITS, &z); glGetIntegerv(GL_STENCIL_BITS, &s); glGetIntegerv(GL_ACCUM_RED_BITS, &a); printf("Depth=%d Stencil=%d Accum=%d\n", z, s, a); } return 0; }
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev