Graphics Reference
In-Depth Information
OpenGL and DirectX, most programmers no longer have to worry about such low-
level issues because those were dealt with by the implementers of those APIs.
Next, we look at another aspect of frame buffers that is very helpful for anima-
tion. Today's frame buffers have hardware support for
(1) lookup tables
(2) panning, and
(3) zooming
Lookup Tables. Users and programmers can reference colors in different ways even
though, at the hardware level, any representation eventually needs to be translated
into RGB values. (We shall have more to say about color in Chapter 8.) One standard
way to reference a color is by means of a number that really is an index into a table.
This table is initialized by the operating system to certain default values. The size of
the table depends on the number of colors that can be displayed simultaneously by
the graphics system. For example, the number 0 is the standard representative for
black. For a 256-color table, the standard number for white would be 255. The actual
color that the hardware can associate to an index is quite arbitrary however and can
be changed by a programmer. In that way, a relatively small table can access a large
number of colors. For example, even if we only have a table of size 256 (8 bits), we
would be able to access an actual 24 bit worth of colors (but only 256 at a time).
Panning. The frame buffer in the graphics hardware might actually be much larger
than the number of pixels on the screen. By using “origin registers” that specify the
location where the electron beam starts its scan in the buffer, the hardware makes
panning easy. One can quickly scroll the image up or down, or left or right, simply by
changing the values in those registers.
Zooming. The zoom feature allows one to display a portion of the image in magni-
fied form. The magnification power is typically a power of 2. What happens is that a
zoom factor of, say 2, would repeat each pixel and scan line twice.
The above-mentioned features allow three interesting forms of animation.
(1) Animation using lookup tables:
We explain this technique with an example. To show a red ball bouncing on a gray
floor and a black background we could set up a picture as shown in Figure 2.24.
Figure 2.24.
Bouncing ball using lookup table.
Search WWH ::




Custom Search