Graphics Reference
In-Depth Information
The various conversions from the continuous geometry of Euclidean space to
the rasterized geometry of the screen (with rasterized textures being used along
the way) involve many subtleties, to be discussed in Chapter 18.
1.9 Polygon Drawing As a Black Box
Given the difficulties of carrying out the steps in the pipeline (especially those
that involve the transformation from continuous to discrete geometry), we can,
for the time being, treat polygon drawing as a black box: We have a graphics
system which, when told to draw a polygon, somehow makes the right pixels on
the display be illuminated with the right colors. This black-box approach will let
us experiment with interaction, color, and coordinate systems. We'll then return
to the details in later chapters.
1.10 Interaction in Graphics Systems
Graphics programs that display images in some form typically feature some level
of user interaction as well. For example, in many programs the user clicks on
things with the mouse, selects menu items, and types at the keyboard. However,
the level of interaction in some programs (indeed, in many 3D games) is far more
complex.
Graphics programs typically support such interaction by having two parallel
threads of execution; one thread handles the main program and the other handles
the GUI. Each component of the GUI—button, checkbox, slider, etc.—is asso-
ciated with a callback procedure in the main program. For instance, when the
user clicks a button the GUI thread calls the button's callback procedure. That
procedure in turn may alter some data, and may also ask the GUI to change
something.
As an example, imagine a trivial game in which a user has to guess a number
that the computer has chosen—either one, two, or three. To do so, the user clicks
on one of three buttons. If the user clicks on the correct button, the display reads
“You win!”; if not, it reads “Try again.” In this scenario, when the user clicks
button 2 but the secret number is 1, the button-2 callback does the following.
1. It checks to see whether 2 was the secret number.
2. Because 2 is not the secret number, it asks the GUI to display the “try
again” message.
3.
It asks the GUI to gray out (disable) the “2” button so that the user is not
able to guess the same wrong answer more than once.
Of course, the button-1 and button-3 callbacks would be very similar, and in
each case, if the guess was correct the button would ask the GUI to display the
fact that the user had won.
For more complex programs, the structure of the callbacks can be far more
complex, of course, but the general idea is this simple one. One speaks of the code
in the callback as the button's “behavior”; thus interaction components have both
appearance and behavior . Not surprisingly, many successful interfaces correlate
the two—the behavior of a component can, to some extent, be inferred by the user
 
 
 
Search WWH ::




Custom Search