Patrick,<br><br>Good thought but it doesn't work. I don't understand why adding -lOSMesa to the following makes everything work. <br><br>gcc -I../../include -g -O2 -Wall -Wmissing-prototypes -std=c99 -ffast-math -fvisibility=hidden -fno-strict-aliasing -g -fPIC -D_GNU_SOURCE -DPTHREADS -DDEBUG -DHAVE_POSIX_MEMALIGN -DUSE_XSHM osdemo.c -L../../lib -lGL -o osdemo<br>
<br>There must be some other initialization I need to call to get things to work but I don't understand enough of the details of Mesa to know what is missing. I've stepped through the mesa context initialization and I cannot see what is different between the two runs. The odd thing is that everything seems to work but then I end up what I believe is an empty gl dispatch table. This is the first time I've looked this so I'm not really sure what to expect. Any ideas of where to look in the Mesa code?<br>
<br>Thanks,<br>Paul<br><br><div class="gmail_quote">On Fri, Jul 15, 2011 at 3:45 PM, Patrick Baggett <span dir="ltr"><<a href="mailto:baggett.patrick@gmail.com" target="_blank">baggett.patrick@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If libOSMesa.so is separate library, then isn't libGL.so too? You're calling glGetIntegerv() from libGL.so but not from libOSMesa.so -- try doing dlsym("glGetIntegerv") and removing libGL.so from the link line.<div>
<br></div><div>Patrick<br><br><div class="gmail_quote"><div><div></div><div>On Fri, Jul 15, 2011 at 2:41 PM, Paul Gotzel <span dir="ltr"><<a href="mailto:paul.gotzel@gmail.com" target="_blank">paul.gotzel@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>
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>
<br></div></div>_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br>