1

I'm trying to disable vertical sync on Linux in a program built around SDL and openGL. I am running an old integrated ATI card with Gallium 0.4 as the driver.

I attempt to disable vsync by calling glXSwapInterval(0) in my code, but when I do this, although the program compiles fine, I get a segfault when I try to run it.

gdb gives me the rather unhelpful message:

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()

Does anyone have any idea as to what might be going on?

genpfault
  • 51,148
  • 11
  • 85
  • 139
user1483596
  • 309
  • 2
  • 12

1 Answers1

4

glXSwapIntervalEXT and glXSwapIntervalSGI are extension functions; You normally access extensions' function addresses through glXGetProcAddress, though some libGL.so may export them directly.

Most easy solution: Get a OpenGL extension loader library, like GLEW (it's in all major Linux distribution's package repositories). Replace all occurances of #include <GL/gl.h> with #include <GL/glew.h> and #include <GL/glx.h> with #include <GL/glxew.h>, add libGLEW.so to your list of linked libraries, and call glewInit() right after creating and binding a OpenGL context. Then test if the extension is actually available!

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Thanks - I was already using `gl/glxew.h` - I was just trying to call `glXSwapInterval` before `glewInit`! After moving the call everything works fine. (I'll accept the answer as soon as I can...) – user1483596 Dec 18 '12 at 13:23