Triple Buffer

Does any one knows what is meant by triple

buffer and The Difference Between it and

double Buffer and

How it Can be implmented in OpenGL ?

Thanks For all of you ?

In double buffering, you have a front and a back buffer, and swap between the two (or copy from the back to the front). This is a standard OpenGL feature.

In triple buffering, you have a front and two back buffers. Let’s call the initial front buffer “A”, the first back buffer “B”, and the second back buffer (if present) “C”.

When double buffering, you are displaying A and drawing to B. When that’s done, you issue a swap (to display B). It may take some time for the swap to happen (for CRTs, it usually happens on vertical retrace to avoid tearing). Until the swap completes, you can’t switch your drawing back to A, since it’s still being displayed. So you’re temporarily stuck. As a practical example, let’s say your app could run at 45 frames per second and the monitor refreshes at 60. This means that each frame takes 1.5 refreshes to draw. If your swaps wait for vertical retrace, you have 0.5 refreshes worth of dead time after each frame. And your app will run at 30 frames per second.

When triple buffering, you can draw to C while waiting for the vertical retrace and will end up getting closer to 45 fps. Effectively, some frames will be displayed for 2 refreshes, while others will be displayed for 1.

If your app runs faster than the monitor refresh, triple buffering doesn’t help much since you’ll eventually get two refreshes behind and end up waiting.

This isn’t much of an issue for benchmarking, since waiting on vblank is usually disabled. In this case, swaps are nearly instantaneous. If you leave vblank on when benchmarking, it would be impossible to distinguish between a system that could run at 59 fps and one that could run at 31 fps in the example above – both would run at 30 fps even though the first one was nearly twice as fast!

not that i want to implement it but
this question often comes up
‘how to do triple buffer in opengl’
the stock answer is
‘its up to the driver’
which is a bit unsatisfactory,
we can use wglSwapInterval (or something like that to swap at the vrefresh)
so how to do triple buffering in opengl. the stock answer sounds like a lottery.

It is a lottery. It’s really a shame.

It could have been worked into the ARB_pixel_format extension easily but the ARB didn’t seem to consider this.
I’d prefer a somewhat clunky WGL_ARB_pixel_format kind of way to control it over no way to control it every day, obviously.

[This message has been edited by zeckensack (edited 10-02-2002).]

I’m not sure you can REALLY support triple buffering at all in OpenGL with the current definition of GL_FRONT and GL_BACK render targets.

However, I would be okay with a pixel format flag (or separate extension) which let me enable triple buffering, and which restricted what I could do with the GL_FRONT buffer, and which made the GL_BACK buffer go undefined after SwapBuffers even when you’re in SWAP_COPY mode (I forget whether this is already the case or not).

My GL implementation (ATI Radeon 8500) defaults to triple buffering* when I cover the whole screen with my OpenL window.

And it defaults to double buffering* when I use ‘windowed’ display.

They already do that. All that’s missing is a way to control it.

*You can easily measure that yourself if you clear/flip/clear/flip/clear/flip a few times with different colors and then only flip/sleep/flip/sleep. Count the different colors you end up with.