Open GL Super Bible

Previous Table of Contents Next


Reference Section

glGetError

Purpose
Returns information about the current error state.
Include File
<gl.h>
Syntax
GLenum glGetError(void);
Description
OpenGL maintains five error flags, listed in Table 5-1. When an error flag is set, it remains set until glGetError is called, at which time it will be set to GL_NO_ERROR. Multiple flags may be set simultaneously, in which case glGetError must be called again to clear any remaining errors. Generally, it is a good idea to call glGetError in a loop to ensure that all error flags have been cleared. If glGetError is called between glBegin and glEnd statements, the GL_INVALID_OPERATION flag is set.
Returns
One of the error flags in Table 5-1. In all cases except GL_OUT_OF_MEMORY, the offending command is ignored and the condition of the OpenGL state variables, buffers, etc., is not affected. In the case of GL_OUT_OF_MEMORY, the state of OpenGL is undefined.
Example
See the GLTELL sample from Listing 5-1.
See Also
gluErrorString
Table 5-1 Valid error return codes from glGetError
Value Meaning

GL_NO_ERROR No errors have occurred.
GL_INVALID_ENUM
GLU_INVALID_ENUM An invalid value was specified for an enumerated argument.
GL_INVALID_VALUE
GLU_INVALID_VALUE A numeric argument was out of range.
GL_INVALID_OPERATION An operation was attempted that is not allowed in the current state.
GL_STACK_OVERFLOW A command was attempted that would have resulted in a stack overflow.
GL_STACK_UNDERFLOW A command was attempted that would have resulted in a stack underflow.
GL_OUT_OF_MEMORY
GLU_OUT_OF_MEMORY There is insufficient memory to execute the requested command.

glGetString

Purpose
Returns a string describing some aspect of the OpenGL implementation.
Include File
<gl.h>
Syntax
const GLubyte *glGetString(GLenum name);
Description
This function returns a string describing some aspect of the current OpenGL implementation. This string is statically defined, and the return address cannot be modified.

Parameters

name
GLenum: Identifies the aspect of the OpenGL implementation to describe. This may be one of the following values:
GL_VENDOR Returns the name of the company responsible for this implementation.
GL_RENDERER Returns the name of the renderer. This can vary with specific hardware configurations. GDI Generic specifies unassisted software emulation of OpenGL.
GL_VERSION Returns the version number of this implementation.
GL_EXTENSIONS Returns a list of supported extensions for this version and implementation. Each entry in the list is separated by a space.
Returns
A character string describing the requested aspect, or NULL if an invalid identifier is used.
Example
See the GLTELL sample from Listing 5-2.
See Also
gluGetString

glHint

Purpose
Allows the programmer to specify implementation-dependent performance hints.
Include File
<gl.h>
Syntax
void glHint(GLenum target, GLenum mode);
Description
Certain aspects of OpenGL behavior are open to interpretation on some implementations. This function allows some aspects to be controlled with performance hints that request optimization for speed or fidelity. There is no requirement that the glHint has any effect, and may be ignored for some implementations.

Parameters

target
GLenum: Indicates the behavior to be controlled. This may be any of the following values:
GL_FOG_HINT Influences accuracy of fog calculations
GL_LINE_SMOOTH_HINT Influences quality of anti-aliased lines.
GL_PERSPECTIVE_CORRECTION_HINT Influences quality of color and texture interpolation.
GL_POINT_SMOOTH_HINT Influences quality of anti-aliased points.
GL_POLYGON_SMOOTH_HINT Influences quality of anti-aliased polygons.
mode
GLenum: Indicates the desired optimized behavior. This may be any of the following values:
GL_FASTEST The most efficient or quickest method should be used.
GL_NICEST The most accurate or highest quality method should be used.
GL_DONT_CARE No preference on the method used.
Returns
None.
Example
The following code is found in the WINHINT supplementary sample program. It tells OpenGL that it should render anti-aliased lines as quickly as possible, even if it has to sacrifice the image quality.
    glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);

gluErrorString

Purpose
Retrieves a string that describes a particular error code.
Include File
<glu.h>
Syntax
const GLubyte* gluErrorString(GLenum errorCode);
Description
This function returns a string describing error code specified. This string is statically defined, and the return address cannot be modified. The returned string is ANSI. To return ANSI or UNICODE depending on the environment, call the macro glErrorStringWIN.

Parameters

errorCode
GLenum: The error code to be described in the return string. Any of the codes in Table5-1 may be used.
Returns
A string describing the error code specified.
Example
See the GLTELL sample from Listing 5-2.
See Also
glGetError

gluGetString

Purpose
Returns the version and extension information about the GLU library.
Include File
<glu.h>
Syntax
const GLubyte *gluGetString(GLenum name);
Description
This function returns a string describing either the version or extension information about the GLU library. This string is statically defined, and the return address cannot be modified.

Parameters

name
GLenum: Identifies the aspect of the GLU library to describe. This may be one of the following values:
GLU_VERSION Returns the version information for the GLU Library. The format of the return string is:
<version number><space><vendor information>
GLU_EXTENSIONS Returns a list of supported extensions for this version of the GLU Library. Each entry in the list is separated by a space.
Returns
A character string describing the requested aspect, or NULL if an invalid identifier is used.
Example
See the GLTELL sample from Listing 5-2.
See Also
glGetString


Previous Table of Contents Next