Note: Implementations of OpenGL have leeway in selecting which C data type to use to represent OpenGL data types. If you
resolutely use the OpenGL defined data types throughout your application, you will avoid mismatched types when porting your
code between different implementations.
Some OpenGL commands can take a final letter v, which indicates that the command takes a pointer to a vector (or array) of
values rather than a series of individual arguments. Many commands have both vector and nonvector versions, but some
commands accept only individual arguments and others require that at least some of the arguments be specified as a vector. The
following lines show how you might use a vector and a nonvector version of the command that sets the current color:
glColor3f(1.0, 0.0, 0.0);
GLfloat color_array[] = {1.0, 0.0, 0.0};
glColor3fv(color_array);
Finally, OpenGL defines the typedef GLvoid. This is most often used for OpenGL commands that accept pointers to arrays of
values.
In the rest of this guide (except in actual code examples), OpenGL commands are referred to by their base names only, and an
asterisk is included to indicate that there may be more to the command name. For example, glColor*() stands for all variations of
the command you use to set the current color. If we want to make a specific point about one version of a particular command, we
include the suffix necessary to define that version. For example, glVertex*v() refers to all the vector versions of the command
you use to specify vertices.
OpenGL as a State Machine
OpenGL is a state machine. You put it into various states (or modes) that then remain in effect until you change them. As you've
already seen, the current color is a state variable. You can set the current color to white, red, or any other color, and thereafter
every object is drawn with that color until you set the current color to something else. The current color is only one of many state
variables that OpenGL maintains. Others control such things as the current viewing and projection transformations, line and
polygon stipple patterns, polygon drawing modes, pixel-packing conventions, positions and characteristics of lights, and material
properties of the objects being drawn. Many state variables refer to modes that are enabled or disabled with the command
glEnable() or glDisable().
Each state variable or mode has a default value, and at any point you can query the system for each variable's current value.
Typically, you use one of the six following commands to do this: glGetBooleanv(), glGetDoublev(), glGetFloatv(),
glGetIntegerv(), glGetPointerv(), or glIsEnabled(). Which of these commands you select depends on what data type you want
the answer to be given in. Some state variables have a more specific query command (such as glGetLight*(), glGetError(), or
glGetPolygonStipple()). In addition, you can save a collection of state variables on an attribute stack with glPushAttrib() or
glPushClientAttrib(), temporarily modify them, and later restore the values with glPopAttrib() or glPopClientAttrib(). For
temporary state changes, you should use these commands rather than any of the query commands, since they're likely to be more
efficient.
See Appendix B for the complete list of state variables you can query. For each variable, the appendix also lists a suggested
glGet*() command that returns the variable's value, the attribute class to which it belongs, and the variable's default value.
OpenGL Rendering Pipeline
Most implementations of OpenGL have a similar order of operations, a series of processing stages called the OpenGL rendering
pipeline. This ordering, as shown in Figure 1-2, is not a strict rule of how OpenGL is implemented but provides a reliable guide
for predicting what OpenGL will do.
If you are new to three-dimensional graphics, the upcoming description may seem like drinking water out of a fire hose. You can
skim this now, but come back to Figure 1-2 as you go through each chapter in this book.
The following diagram shows the Henry Ford assembly line approach, which OpenGL takes to processing data. Geometric data
(vertices, lines, and polygons) follow the path through the row of boxes that includes evaluators and per-vertex operations, while
http://heron.cc.ukans.edu/ebt-bin/nph-dweb/dynaw...PG/@Generic__BookTextView/622;cs=fullhtml;pt=532 (6 of 16) [4/28/2000 9:44:16 PM]