Game Development Reference
In-Depth Information
Chapter 2. 2D Graphics
With the explosion of web, smartphone, and indie games, 2D has had a
renaissance of sorts. Developers are drawn to 2D because the typical
budget and team can be much smaller. Gamers are drawn toward 2D
because of the purity and simplicity of the games.
Though the primary focus of this topic is on 3D games, it would be a
mistake not to cover the core concepts behind 2D graphics. It also
should be noted that many of the topics covered in latter chapters,
whether physics, sound, or UI programming, are equally applicable in
both 2D and 3D games.
2D Rendering Foundations
To fully understand 2D rendering, it is important to understand the limitations of
display devices when these techniques were first developed. Even though we now
almost exclusively use LCD or plasma displays, many of the rendering concepts
that were originally developed with older monitors in mind are still in use today.
CRT Monitor Basics
For many years, cathode ray tube (CRT) displays were the predominant display
technology. A CRT features an array of picture elements known as pixels . For a
color display, each pixel contains a red, green, and blue sub-pixel, which can then
be combined to create specific colors. The resolution of the display determines the
totalnumberofpixels.Forinstance,a300×200displaywouldhave200totalrows,
or scan lines ,and each scan line would have 300pixels, fora grand total of60,000
pixels. The (0,0) pixel usually refers to the top-left corner, though not all displays
follow this format.
In a CRT, all of the drawing is done by an electron gun that fires a narrow stream
of electrons. This gun starts drawing in the top-left corner of the screen and shifts
its aim across horizontally to draw the first scan line (see Figure 2.1 ) . It then re-
positions its aim so it can start all the way at the start of the subsequent scan line,
repeating this process until all scan lines have been drawn.
Search WWH ::




Custom Search