tags:

views:

74

answers:

2

I'm getting a segfault that GDB says is coming from SDL_GL_SwapBuffers. However, I can't imagine why. The SDL documentation mentions no specific pre-conditions for calling swapBuffers except that double buffering be allowed. Is this an option I have to turn on while initializing OpenGL or is this a hardware capability thing?

My code:

http://pastie.org/859721

(Ignore the unused variables, strange comments and other things. I haven't prettied this up at all. :P)

A: 

Why are you mixing gl and SDL calls? Seems like SDL should give you an OpenGL context and make it active, then you could call glSwapBuffers.

Ben Voigt
This is fairly common...and glSwapBuffers doesn't exist that I can find. There's glutSwapBuffers, and glxSwapBuffers....swapping buffers is more of a function of the windowing toolkit (SDL in this case).
Timothy Baldridge
ack, you're right! Too much time using a toolkit that puts wgl* and gl* functions into a single class and strips the prefix, I guess.
Ben Voigt
+1  A: 

Documentation says:

Description

Swap the OpenGL buffers, if double-buffering is supported.

You are using SDL_GL_SwapBuffers() without enabling double-buffering.


SDL_Surface *screen = SDL_SetVideoMode(800, 600, 32, SDL_DOUBLEBUF | SDL_HWSURFACE);
Bertrand Marron
This worked! Thank you :)
RyanG