OpenGL replaces the IRIS GL function, greset, with the functions, glPushAttrib and glPopAttrib. Use these functions to save and restore groups of state variables. For example,
void glPushAttrib( GLbitfield mask );
This example takes a bitwise OR of symbolic constants, indicating which groups of state variables to push onto an attribute stack. Each constant refers to a group of state variables. The following table shows the attribute groups with their equivalent symbolic constant names. For a complete list of the OpenGL state variables associated with each constant, see glPushAttrib.
Attribute | Constant |
---|---|
accumulation buffer clear value | GL_ACCUM_BUFFER_BIT |
color buffer | GL_COLOR_BUFFER_BIT |
current | GL_CURRENT_BIT |
depth buffer | GL_DEPTH_BUFFER_BIT |
enable | GL_ENABLE_BIT |
evaluators | EGL_VAL_BIT |
fog | GL_FOG_BIT |
GL_LIST_BASE setting | GL_LIST_BIT |
hint variables | GL_HINT_BIT |
lighting variables | GL_LIGHTING_BIT |
line drawing mode | GL_LINE_BIT |
pixel mode variables | GL_PIXEL_MODE_BIT |
point variables | GL_POINT_BIT |
polygon | GL_POLYGON_BIT |
polygon stipple | GL_POLYGON_STIPPLE_BIT |
scissor | GL_SCISSOR_BIT |
stencil buffer | GL_STENCIL_BUFFER_BIT |
texture | GL_TEXTURE_BIT |
transform | GL_TRANSFORM_BIT |
viewport | GL_VIEWPORT_BIT |
— | GL_ALL_ATTRIB_BITS |
To restore the values of the state variables to those saved with the last glPushAttrib, simply call glPopAttrib. The variables you didn't save will remain unchanged. The attribute stack has a finite depth of at least 16.