Game Development Community

Flipping OpenGL

by William Finlayson · in Technical Issues · 09/04/2002 (4:36 pm) · 1 replies

I have been using SDL combined with openGL to create 3D graphics, but the way it swaps buffers is bugging me.

When setting the screen mode with SDL, I request a hardware screen-buffer. But when I flip the screen-buffers using SDL_GL_SwapBuffers() it seems to copy the back-buffer to the front-buffer, rather then flipping the buffer addressed. I'm guessing this is the case, as the contents of the buffer are not lost when I flip the screen. Is it actually flipping the buffers, and preserving the contents or is it blitting the back to the front buffer? Does the behaviour of flipping depend on OpenGL, or is the behaviour determined by the code that created the buffer? Or rather does the same thing happen when you create a win32 window, and draw to that with OpenGL, or is it dependant on the window code?

Is there actually any way of dictating how the buffer swap is performed under openGL - is there a command that lets you tell openGL to perform a fast flip, discarding the buffer's contents? The reason I'm asking, is because before this I was using D3D, where every little detail needs to be explicitly set.

#1
02/15/2003 (1:47 pm)
OpenGL doesnt discard the contents of a buffer, it just flips between the 2 buffers (assuming double buffering is on) so you get the contents of the frame before last in your buffer. You do need to use the flag SDL_DOUBLEBUF in setvideomode though. Otherwise sdl just performs an UpdateRect instead. SDL_HWSURFACE might help too.