From: Brian P. <br...@vm...> - 2009-12-04 15:15:05
|
Geng, Xiujuan (NIH/NIDA) [C] wrote: > Hi, > > I'm new to mesa and openGL. I'm trying to do offscreen rendering on a 64bit Suse Linux machine. > > I started from a mesa demo code progs/osdemos/osdemo.c. I copied the main part below: > > /* Create an RGBA-mode context */ > #if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 > /* specify Z, stencil, accum sizes */ > ctx = OSMesaCreateContextExt( OSMESA_RGBA, 16, 0, 0, NULL ); > #else > ctx = OSMesaCreateContext( OSMESA_RGBA, NULL ); > #endif > if (!ctx) { > printf("OSMesaCreateContext failed!\n"); > return 0; > } > > /* 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 (!OSMesaMakeCurrent( 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); > } > render_image(); > > I compiled the code with no problem: > gcc osdemo.c -lglut -lGLU -lOSMesa -lm -o osdemo > > But when I run it: > ./osdemo output.ppm 400 400 > > It gave me a seg fault. I used gdb to debug it, and the error message is: > > (gdb) run > Starting program: /data/380/gengx/tools/Mesa-7.5.1/progs/osdemos/osdemo output.ppm 400 400 > [Thread debugging using libthread_db enabled] > > Program received signal SIGSEGV, Segmentation fault. > glGetIntegerv () at ../../../src/mesa/x86-64/glapi_x86-64.S:9444 > 9444 movq 2104(%rax), %r11 > Current language: auto; currently asm > > Our own offscreen code (also using " OSMesaCreateContextExt " and " OSMesaMakeCurrent ") faced the same segmentation problem. Basically it gave a segmentation at whatever gl routine first called in the code. > > We are currently using mesa7.7. > > Any suggestion is appreciated! Thanks. Can you run w/ valgrind and see if that finds anything? Does the original osdemo.c work properly? Maybe try disabling x86-64 optimizations or a debug build of Mesa. -Brian |