i
i
i
i
i
i
i
i
18
Peter Willemsen
Using Graphics Hardware
Throughout most of this book, the focus has been on the fundamentals underlying
computer graphics rather than on implementation details. This chapter takes a
slightly different route and blends the details of using graphics hardware with the
practical issues associated with programming that hardware.
This chapter, however, is not written to teach you OpenGL,
TM
other graphics
APIs, or even the nitty gritty specics of graphics hardware programming. The
purpose of this chapter is to introduce the basic concepts and thought processes
that are necessary when writing programs that use graphics hardware.
18.1 What Is Graphics Hardware
Graphics hardware describes the hardware components necessary to quickly ren-
der 3D objects as pixels on your computer’s screen using specialized rasterization-
based hardware architectures. The use of this term is meant to elicit a sense of
the physical components necessary for performing these computations. In other
words, we’re talking about the chipsets, transistors, buses, and processors found
on many current video cards. As we will see in this chapter, current graphics
hardware is very good at processing descriptions of 3D objects and transforming
them into the colored pixels that ll your monitor.
One thing has been certain with graphics hardware: it changes very quickly
with new extensions and features being added continually! One explanation for
the fast pace is the video game industry and its economic momentum. Essentially
445
i
i
i
i
i
i
i
i
446 18. Using Graphics Hardware
Geometry
Processing
Pixel
Processing
User
Program
primitives
2D screen
coordinates
Figure 18.1. The basic graphics hardware pipeline consists of stages that transform 3D
data into 2D screen objects ready for rasterizing and coloring by the pixel processing stages.
what this means is that each new graphics card provides better performance and
processing capabilities. As a result, graphics hardware is being used for tasks
that support a much richer use of 3D graphics. For instance, researchers are per-
forming computation on graphics hardware to perform ray-tracing (Purcell et al.,
2002) and even solve the Navier-Stokes equations to simulate uid ow (Harris,
2004).
Real-Time Graphics:By
real-time graphics, we
generally mean that the
graphics-related compu-
tations are being carried
out fast enough that the
results can be viewed
immediately. Being able
to conduct operations at
60Hz is considered real
time. Once the time to
refresh the display (
frame
rate
) drops below 15Hz,
the speed is considered
more interactive than it is
real-time, but this distinc-
tion is not critical. Because
the computations need to
be fast, the equations used
to render the graphics are
often approximations to
what could be done if more
time were available.
Most graphics hardware has been built to perform a set of xed operations
organized as a pipeline designed to push vertices and pixels through different
stages. The xed functionality of the pipeline ensures that basic coloring, lighting,
and texturing can occur very quickly—often referred to as real-time graphics.
Figure 18.1 illustrates the real-time graphics pipeline. The important things
to note about the pipeline follow:
The user program, or application, supplies the data to the graphics hardware
in the form of primitives, such as points, lines, or polygons describing the
3D geometry. Images or bitmaps are also supplied for use in texturing
surfaces.
Geometric primitives are processed on a per-vertex basis and are trans-
formed from 3D coordinates to 2D screen triangles.
Screen objects are passed to the pixel processors, rasterized, and then col-
ored on a per-pixel basis before being output to the frame buffer, and even-
tually to the monitor.
18.2 Describing Geometry for the Hardware
As a graphics programmer, you need to be concerned with how the data associ-
ated with your 3D objects is transferred onto the memory cache of the graphics
hardware. Unfortunately (or maybe fortunately), as a programmer you don’t have
complete control over this process. There are a variety of ways to place your

Get Fundamentals of Computer Graphics, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.