Game Development Reference
In-Depth Information
1.3.5 The Swap Chain and Page Flipping
Direct3D maintains a collection of surfaces, usually two or three, called
a swap chain that is represented by the IDirect3DSwapChain9
interface. We do not go into the specifics of this interface since
Direct3D manages it and we rarely need to manipulate it. Instead we
will simply outline the purpose of it.
Swap chains and, more specifically, the technique of page flipping
are used to provide smooth animation between frames. Figure 1.4
shows a swap chain graphically with two surfaces.
Figure 1.4: A swap chain with
two surfaces: a front buffer
and a back buffer
In Figure 1.4, the surface in the front buffer slot is the surface that cor-
responds to the image presently being displayed on the monitor. The
monitor does not display the image represented by the front buffer
instantaneously; it takes one-sixtieth of a second on a monitor with a
refresh rate of 60 hertz, for instance. The application's frame rate is
often out of sync with the monitor's refresh rate (for example, the
application may be able to render frames faster than the monitor can
display them). However, we do not want to update the contents of the
front buffer with the next frame of animation until the monitor has fin-
ished drawing the current frame, but we do not want to halt our
rendering while waiting for the monitor to finish displaying the con-
tents of the front buffer either. Therefore, we render to an off-screen
surface ( back buffer ); then when the monitor is done displaying the sur-
face in the front buffer, we move it to the end of the swap chain and the
next back buffer in the swap chain is promoted to be the front buffer.
This process is called presenting . Figure 1.5 shows the swap chain
before and after a presentation.
Search WWH ::




Custom Search