Advertisement

What happens to the front buffer after it has been swapped?

Started by September 04, 2004 06:47 PM
4 comments, last by GameDev.net 20 years, 2 months ago
Hi, this is a quick question. What happenes to the front buffer after I swap buffers, assuming I am in double buffering mode? Will the new back buffer contain the same data as what it had when it was the front buffer, or does it now contain something undefined? Thanks in advance for the reply. Coco
Well, I would guess it would contain the same data as when it was first drawn until it gets overwritten. It would be quite an expensive memory operation to clear the back buffer just so you can draw on it again. So, halfway through drawing the back buffer, the back buffer would contain half new image and half old image. I think this can be seen by opening a new empty OpenGL window while another is in use. I don't remember where I read this, but if you do it, you'll see the previous frame of the non empty OpenGL window.
"Donkey, if it were me, you'd be dead."I cna ytpe 300 wrods pre mniute.
Advertisement
Quote: Quote MSDN
The SwapBuffers function exchanges the front and back buffers if the current pixel format for the window referenced by the specified device context includes a back buffer.


The data is not destroyed just swaped between the buffers.
The data is however undefined if the buffer in question has not been used before.
Thank you for the replies. I have a further question.

Is it true that in the main rendering function, right before I swap the buffers, like GlutSwapBuffers(), I have actually already rendered the the entire scene to the back buffer, and the buffer-swapping function is just to tell OpenGL that now to use the back buffer as the front buffer, and front as the back?

As always, thanks in advance for the reply.

Coco
Quote: Original post by Coconut Crab
Thank you for the replies. I have a further question.

Is it true that in the main rendering function, right before I swap the buffers, like GlutSwapBuffers(), I have actually already rendered the the entire scene to the back buffer, and the buffer-swapping function is just to tell OpenGL that now to use the back buffer as the front buffer, and front as the back?

As always, thanks in advance for the reply.

Coco


I don't know whether that's in the specification, but all implementations that I've heard of do just a pointer swap, as you describe. It's much faster than actually copying the data.
If at first you don't succeed, redefine success.
Can someone please give me a code example on how to render an image to a user defined buffer?

Thank you.

Coco

This topic is closed to new replies.

Advertisement