This appendix provides some background information on OpenGL command names, defined types, and error handling. It's intended mainly as a quick reference. For more detailed information, refer to the OpenGL Programming Guide.
This section describes the naming convention for OpenGL calls. For a complete list of OpenGL equivalents to IRIS GL routines, see Appendix A, “OpenGL Commands and Their IRIS GL Equivalents.”
gl—OpenGL commands begin with the gl prefix (glEnable(), glTranslatef(), and so on).
glu—OpenGL Utility Library (GLU) commands begin with the glu prefix (gluDisk(), gluErrorString(), and so on).
glX—Commands that belong to the OpenGL extension to X (GLX) begin with the glX prefix (glXChooseVisual(), glXCopyContext(), and so on).
glut—Commands in the GLUT (OpenGL Utility Toolkit) library begin with a glut prefix (glutInit, glutMenuStatusFunc, and so on).
OpenGL commands are formed by a root name, optionally followed by up to four characters. The first character indicates the number of arguments. The second character, or pair of characters, specifies the type of the arguments. Table C-1 lists the character suffixes and the corresponding argument types (some of these values might be different on a 64-bit architecture).
32-bit floating point
64-bit floating point
8-bit unsigned integer
16-bit unsigned integer
32-bit unsigned integer
The final character, if present, is v. The v indicates that the command takes a pointer to an array of values—a vector—rather than a series of individual arguments.
IRIS GL used a similar mechanism for some commands. The predecessor to glVertex*(), for example, was v(), which also used a suffix to specify the number and type of its arguments.
Here are some examples of OpenGL command naming:
void glVertex2i( GLint x, GLint y);
void glVertex3f( GLfloat x, GLfloat y, GLfloat z); void glVertex3dv( const GLdouble *v) ;
The first version of the vertex call, glVertex2i(), takes two integer arguments. The second, glVertex3f(), is a three-dimensional version, which expects three floats. The third version, glVertex3dv(), expects an argument in the form of a vector, which is a pointer to an array. In this case, the array should have three elements.
Table C-2 lists C data types and their equivalent OpenGL defined types.
Equivalent OpenGL Type
double value clamped to [ 0.0, 1.0 ]
float value clamped to [ 0.0, 1.0 ]
When an error occurs, OpenGL sets an error flag to the appropriate error value. You can test error conditions using the glGetError() call, which returns the error number. Table C-3 lists possible error values. For details, see the reference page for glGetError().
Enumerated argument out of range
Numeric argument out of range
Operation illegal in current state
Command would cause a stack overflow
Command would cause a stack underflow
Not enough memory left to execute command