Next: 2.2 Two Color Models Up: 2 OpenGL's Functionality Previous: 2 OpenGL's Functionality

2.1 Observations About Primitives

OpenGL tends to be function call intensive. There is not a complex RenderPolygonWithGratuitousArguments command. Instead primitives are constructed by calling multiple OpenGL routines. Calling multiple routines gives the program flexibility and control over the primitives generated.

OpenGL is flexible about what format information is passed to it. For example, the glVertex3i accepts integers while glVertex3f and glVertex3d take single and double precision floating point respectively. It is very advantageous for OpenGL to have several basically identical routines which accept different data types. It allows the programmer the flexibility to decide how to store the data. A programmer whose data is in integer format does not want to convert it to floating point to pass it to the graphics system. And another programmer does not want to convert floating point data into integers. Conversions between data types can be expensive. High performance graphics hardware can be designed to accept multiple data formats and totally off load the task of format conversion from the host processor.

You can start to see why it makes sense to consider OpenGL as a state machine. Commands such as glColor3f change the state of the current color. Subsequent vertices use the current color. glBegin puts OpenGL into a state to start drawing the specified primitive. The multiple glVertex routines load up one at a time the vertices for a given primitive. Nearly all of OpenGL's state that can be set by the programmer can also be queried by the programmer. The glGetFloatv(GL_CURRENT_COLOR, &float_array) call, for example, will retrieve the setting of the current color.


mjk@asd.sgi.com
Wed Oct 19 18:06:42 PDT 1994