Game Engine Architecture

(Ben Green) #1

440 10. The Rendering Engine


We can render triangles expressed in homogeneous clip space by simply
drawing their (x, y) coordinates and ignoring z. But before we do, we scale
and shift the clip-space coordinates so that they lie in screen space rather than
within the normalized unit square. This scale-and-shift operation is known as
screen mapping.

10.1.4.6. The Frame Buffer
The fi nal rendered image is stored in a bitmapped color buff er known as the
frame buff er. Pixel colors are usually stored in RGBA8888 format, although other
frame buff er formats are supported by most graphics cards as well. Some com-
mon formats include RGB565, RGB5551, and one or more palett ed modes.
The display hardware (CRT, fl at-screen monitor, HDTV, etc.) reads the
contents of the frame buff er at a periodic rate of 60 Hz for NTSC televisions
used in North America and Japan, or 50 Hz for PAL /SECAM televisions used
in Europe and many other places in the world. Rendering engines typically
maintain at least two frame buff ers. While one is being scanned by the dis-
play hardware, the other one can be updated by the rendering engine. This is
known as double buff ering. By swapping or “fl ipping” the two buff ers during
the vertical blanking interval (the period during which the CRT’s electron gun is
being reset to the top-left corner of the screen), double buff ering ensures that
the display hardware always scans the complete frame buff er. This avoids a
jarring eff ect known as tearing , in which the upper portion of the screen dis-
plays the newly rendered image while the bott om shows the remnants of the
previous frame’s image.
Some engines make use of three frame buff ers—a technique aptly known
as triple buff ering. This is done so that the rendering engine can start work on
the next frame, even when the previous frame is still being scanned by the
display hardware. For example, the hardware might still be scanning buff er A
when the engine fi nishes drawing buff er B. With triple buff ering, it can pro-

xS

yS 4:3

xS

yS 16:9

Figure 10.35. The two most prevalent screen space aspect ratios are 4:3 and 16:9.
Free download pdf