I've been asked to explain the video model above to peopel whose only experence with Video is the 'at-arms-length" thinsg you do with AWT.
First, forget about AWT., We are going aroudn it here and for very good reasons. AWT gives you niether the performance nor the control necessary for cutting edge games.
I'm going to start by explaing the Full Screen buffer flipping model and then, by extension, will talk about the windowed mode version.
Your graphics card has a big hunk of RAM on it. Only a small part of that RAM is displayed on screen at any given time. Which part is displayed is controlled by something called the "video pointer."
The video pointer points at the memory for the first pixel on your screen. (Usually the top left one in order to match the right-to-left and top-to-bottom way video monitors scan out pixels. Otehr mreo complex hardware designs are possible though where the system corrects for the mismatch when displaying video by doing things like starting at the last pixel and scanning backwards through memory.)
The memory from the start pixel up to the last displayable pize is displayed. So for instance if yo uare in 32 bit (4byte) pixel mode and are set to 1024 x 768 resolution, the next 1024 * 768 * 4 = 3145728 bytes = 3 megabytes of RAM is displayed.
Now most vidoe cards have at least 16meg of ram these days. This means that you could fit up to 5 of these screens on the card at once. By simply changing the video pointer from one screen to the next, you can animate at up to the frame scan rate (typically abt 70hz) the same way you animate with a flip book.
Okay, got that much? There's more.
Video card RAM is special in other ways. All the vidoe card's hardware accellerated drawing capailities draw to video ram. If you copy image data from vidoe RAM to video RAM it is also much faster then ciopying to or from the computer's main memory.
Okay so heres how it all gets put together. I'll describe double buffer ing first and then show why in practice its best to extend to trippel buffering.
In double buffering you have one image on the screen and one in vidoe ram not yet displayed. You do all your drawing to that image and, when it is done, with the write of a single pointer, flip the screens. Since all the drawing is hidden and the flip only happens when you are done, you get nice clean aniamtion frames similar to (but much faster then) what double buffering in AWT gives you.
Assuming you can draw your screens at the scan rate of the video montior or better you can get animation rates up to the reresh rate of your monitor.
In order to draw those frames msot efficiently, the image soruces for thinsg like ships, players, etc are also ideally held in another part of video RAM.
So thats double buffering, why do we nother to tripple buffer? The reason is this. Remember earlier I talked about how video pixels are scanned squentially otu of memory? Thsi is because video monitors really only draw one pixel at a time. They "scan" them out very quickly in left-to-right rows from top-to-bottom-- so quickly yo uarent even aware of it. When its done, it moves its pixel-crayon (the electron gun beam) back to the top corner and starts all over again. The period of time in which it is moving that pixel-crayon back is called the "video retrace."
If I were to chnage the video pointer while the pixel-crayon is in motion across the screen, I would get part of one frame in the pixels already drawn and part of the next frame in the pixels drawn after the change. This is what causes the visual phenomenon of "video tear".
The solution is to wait to change the video pointer until the video retrace. This action of waiting for the video retrace is called scan-synchronization.
What does all this have to do with tripple buffering? I'm glad you asked
Lets say we finish drawing a frame and are now waiting for video retrace. W cannot make any chnages to the buffer that is waiting for display, its done. We cannot make any changes to the currently displayed buffer because its still on the screen. The result is that all drawing stops while we wait for the video retrace. Thsi is wasteful and hurts your frame rate.
If we had ANOTHER buffer we could start drawing to it without waiting for the video retrace. Enter tripple buffering. In a tripple buffering scheme you have a ring of 3 buffers that are displayed in sequence. At any given time one is on the screen, one can be waiting to be displayed, and one is being drawn to.
And THATS how full screen buffer flipping works. BufferStrategy builds the buffer chain and manages it for you so all you need to do is request a graphics for the current buffer to draw to, darw to it, tell BufferStrategy to advance and show the next frame, and do it again.
Whew. Got all that? Time for the last complication. Buffer Stratgey cna be used in Windowed as well as FullScreen mode. How does that work? if you change the video pointer you lose everything that in all the other windows on the screen.
The answer is that it fakes it. It still gives you an offscreen buffer to draw to but rather then flipping the video pointer, when you request it to advance it copies the next frames data into the window's area in the displayed image.
Windows APIs provide no way to scan synchronize such a copy (an oversight on their part) so some tearing can and will occur in this mode.