Silicon Graphics

[Prev] [TOC] [Next]



(-) OpenGL Programming Guide
(-) Appendix BOpenGL State Variables

Error Handling

When OpenGL detects an error, it records a current error code. The command that caused the error is ignored, so it has no effect on OpenGL state or on the framebuffer contents. (If the error recorded was GL_OUT_OF_MEMORY, however, the results of the command are undefined.) Once recorded, the current error code isn't cleared - that is, additional errors aren't recorded - until you call the query command glGetError(), which returns the current error code. In distributed implementations of OpenGL, there might be multiple current error codes, each of which remains set until queried. Once you've queried all the current error codes, or if there's no error, glGetError() returns GL_NO_ERROR. Thus, if you obtain an error code, it's good practice to continue to call glGetError() until GL_NO_ERROR is returned to be sure you've discovered all the errors. Table B-1 lists the defined OpenGL error codes.

You can use the GLU routine gluErrorString() to obtain a descriptive string corresponding to the error code passed in. This routine is described in more detail in "Describing Errors." Note that GLU routines often return error values if an error is detected. Also, the GLU defines the error codes GLU_INVALID_ENUM, GLU_INVALID_VALUE, and GLU_OUT_OF_MEMORY, which have the same meaning as the related OpenGL codes.

Error CodeDescription

GL_INVALID_ENUM

GLenum argument out of range

GL_INVALID_VALUE

Numeric argument out of range

GL_INVALID_OPERATION

Operation illegal in current state

GL_STACK_OVERFLOW

Command would cause a stack overflow

GL_STACK_UNDERFLOW

Command would cause a stack underflow

GL_OUT_OF_MEMORY

Not enough memory left to execute command

Table B-1 : OpenGL Error Codes



[Prev] [TOC] [Next]

OpenGL Programming Guide


Maintained by Maintainer: Send e-mail to .htm">name@address.