SDL Segfault on glXMakeCurrent

I am a developer for the 3D library G3D
(http://g3d-cpp.sourceforge.net/). While testing the library on linux,
I recently ran into some troubles with using SDL and glXMakeCurrent –
together they seem to always produce a segmentation fault. I was able
to create a simple test case where the error is 100% reproducible.
Could someone help me pinpoint my troubles?

#include <SDL.h>
#include <SDL_syswm.h>
#include <GL/glx.h>

int main () {
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
SDL_Surface *mScreen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL);

SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);

GLXContext _glContext = glXGetCurrentContext(); 
Display* _X11Display = info.info.x11.display;
Window _X11Window = info.info.x11.window; 

glXMakeCurrent(_X11Display, _X11Window, _glContext);

}

My link line is: g++ -o test -I/usr/include/SDL test.cpp -lSDL -lGL

I traced the code using gdb and found that executing glXMakeCurrent
triggers the Segmentation Fault. I am using the following specifications:

SDL 1.2.11
ATI’s fglrx linux driver 8.27.10 on an ATI Radeon Mobility x600
Ubuntu Dapper Drake
Linux Kernel 2.6.15-26-686 (reproducible on multiple kernels)
Pentium 4 (HP zd8000 notebook)

Thanks,

Dan

No problem fo me unduer ubuntu dapper with nvidia drivers.

Try this :—
#include <SDL.h>
#include <SDL_syswm.h>
#include <GL/glx.h>

#include <unistd.h>

int main () {
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
SDL_Surface *mScreen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL);

SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);

info.info.x11.lock_func();
GLXContext _glContext = glXGetCurrentContext(); 
Display* _X11Display = info.info.x11.display;
Window _X11Window = info.info.x11.window; 

glXMakeCurrent(_X11Display, _X11Window, _glContext);
info.info.x11.unlock_func();

sleep(5);
SDL_Quit();

}

Laurent Carlier wrote:

No problem fo me unduer ubuntu dapper with nvidia drivers.

Try this :

#include <SDL.h>
#include <SDL_syswm.h>
#include <GL/glx.h>

#include <unistd.h>

int main () {
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
SDL_Surface *mScreen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL);

SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);

info.info.x11.lock_func();
GLXContext _glContext = glXGetCurrentContext(); 
Display* _X11Display = info.info.x11.display;
Window _X11Window = info.info.x11.window; 

glXMakeCurrent(_X11Display, _X11Window, _glContext);
info.info.x11.unlock_func();

sleep(5);
SDL_Quit();

}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Same problem. When I substitute glXGetCurrentDisplay () for
info.info.x11.display, it runs fine. I don’t believe that code has an
identical effect, though.

Dan

I was able to narrow the problem to ATI cards only. Does anyone know
what could be causing this?

Dan

Daniel J. Hilferty wrote:> Laurent Carlier wrote:

No problem fo me unduer ubuntu dapper with nvidia drivers.

Try this :

#include <SDL.h>
#include <SDL_syswm.h>
#include <GL/glx.h>

#include <unistd.h>

int main () {
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
SDL_Surface *mScreen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL);

SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);

info.info.x11.lock_func();
GLXContext _glContext = glXGetCurrentContext(); 
Display* _X11Display = info.info.x11.display;
Window _X11Window = info.info.x11.window; 

glXMakeCurrent(_X11Display, _X11Window, _glContext);
info.info.x11.unlock_func();

sleep(5);
SDL_Quit();

}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Same problem. When I substitute glXGetCurrentDisplay () for
info.info.x11.display, it runs fine. I don’t believe that code has an
identical effect, though.

Dan


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl