RyanG
RyanG

Reputation: 7213

SDL_GL_SwapBuffers Segfault

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)

Upvotes: 1

Views: 1829

Answers (2)

Bertrand Marron
Bertrand Marron

Reputation: 22210

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);

Upvotes: 3

Ben Voigt
Ben Voigt

Reputation: 283644

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.

Upvotes: 0

Related Questions