PDA

View Full Version : Double Buffer Drawing



lobstah
04-17-2002, 03:42 PM
Hi,
I have a complex scene (terrian + a number of balls rolling around in it). What I would like to do is draw the terrian to the back buffer (doesn't update to often, but it does get updated) and use the front buffer for the movement of the balls. Graphically, drawing the balls isn't that tough, but computing there movement does take some time. This coupled with rendering the entire scene each frame is slow.

Is this possible with fairly smooth animation?

JML
04-17-2002, 09:18 PM
Lobstah,

I don't think the back buffer can be used in such a way easily, because you have to issue a SwapBuffer in order to get the image of the terrain from the back buffer into the front buffer before drawing the balls.
Unfortunately, swapping buffers usually leaves the back buffer in an undefined state. There are some cards that support extensions to keep the back buffer intact, or swap the image from the front buffer into the back buffer, but that certainly is not universally available.

An approach that may work is to render the terrain once and then extract that image (including the depth values) (glReadPixels). Then, as long as the camera orientation does not change you start your frame with a glDrawPixels of the previously stored image and then draw the moving stuff.
Do keep in mind though that glReadPixels tends to be a slow operation.

Have you considered other optimization techniques, like using display lists for the terrain?

HTH

Jean-Marc

lobstah
04-18-2002, 01:18 AM
Hi Jean,
I had a feeling this was the case. I did some reading on auxilary buffers, etc. and came to the same conclusion. I was hoping that there was trick available.

I am now using display lists and concentrating on optimizing processing throughput.

Thanks for taking the time to respond.

Have a great day! http://www.opengl.org/discussion_boards/ubb/smile.gif

Lobstah...