28.2. OpenGL State Variables and Inventor

If you need to combine Inventor and OpenGL calls, Table 28.1, “OpenGL State Variables: Current Values and Associated Data through Table 28.9, “OpenGL State Variables: Miscellaneous list the OpenGL state variables and describe which Inventor nodes (or actions) change those variables. If Inventor uses the current value of an OpenGL state variable and never changes it, the variable is omitted from this set of tables. See the OpenGL Programming Guide for a complete list of all OpenGL state variables and their default values. The recommended value for these variables is the default value, with two exceptions: turn on z-buffering and use RGB color mode.

Remember, the constructor for SoGLRenderAction SoGLRenderAction SoGLRenderAction takes a parameter that specifies whether to inherit the current OpenGL values. If you specify TRUE, Inventor inherits values from OpenGL. If you specify FALSE (the default), Inventor sets up its own reasonable default values (see Chapter 8, Applying Actions).

To save and restore OpenGL state, use the OpenGL pushAttributes() and popAttributes() commands. For example, if you change variables in the OpenGL state in a callback node, you need to restore the state when the callback node is finished. Note that if your callback node begins with a pushAttributes() and ends with a popAttributes(), but a render abort occurs in between, popAttributes() is never called and the state is not restored.

Table 28.1. OpenGL State Variables: Current Values and Associated Data

OpenGL State Variable

Inventor Nodes That Change This Variable

GL_CURRENT_COLOR

Shapes, Material, Base Color

GL_CURRENT_INDEX

Color Index node, Shapes

GL_CURRENT_TEXTURE_COORDS

Shapes, TextureCoordinate2

GL_CURRENT_NORMAL

Shapes, Normal

GL_CURRENT_RASTER_POSITION

Text2

GL_CURRENT_RASTER_COLOR

Text2

GL_CURRENT_RASTER_INDEX

Text2

GL_CURRENT_RASTER_POSITION_- VALID

Text2

Table 28.2. OpenGL State Variables: Transformation State

OpenGL State Variable

Inventor Nodes That Change This Variable

GL_MODELVIEW_MATRIX

Transformation nodes, Cameras

GL_PROJECTION_MATRIX

Cameras

GL_TEXTURE_MATRIX

Texture2Transform

GL_VIEWPORT

Cameras

GL_DEPTH_RANGE

Cameras

GL_MODELVIEW_STACK_DEPTH

Transformation nodes

GL_TEXTURE_STACK_DEPTH

Texture2Transform

GL_MATRIX_MODE

Cameras, Texture2Transform

Table 28.3. OpenGL State Variables: Coloring

OpenGL State Variable

Inventor Nodes That Change This Variable

GL_FOG_COLOR

Environment node

GL_FOG_INDEX

Environment node

GL_FOG_DENSITY

Environment node

GL_FOG_START

Environment node

GL_FOG_END

Environment node

GL_FOG_MODE

Environment node

GL_FOG

Environment node

GL_SHADE_MODEL

Light Model, if in color index mode

Table 28.4. OpenGL State Variables: Lighting

OpenGL State Variable

Inventor Nodes That Change This Variable

GL_LIGHTING

Light Model

GL_COLOR_MATERIAL

Shapes

GL_MATERIAL_PARAMETER

Shapes

GL_MATERIAL_FACE

Shapes

GL_AMBIENT

Shapes, Material

GL_DIFFUSE

Shapes, Material

GL_SPECULAR

Shapes, Material

GL_EMISSION

Shapes, Material

GL_SHININESS

Shapes, Material

GL_LIGHT_MODEL_AMBIENT

Shapes, Material

GL_LIGHT_MODEL_LOCAL_VIEWER

Shapes, Material

GL_LIGHT_MODEL_TWO_SIDE

Shape Hints

GL_AMBIENT

Lights

GL_DIFFUSE

Lights

GL_SPECULAR

Lights

GL_POSITION

Lights

GL_CONSTANT_ATTENUATION

Environment

GL_LINEAR_ATTENUATION

Environment

GL_QUADRATIC_ATTENUATION

Environment

GL_SPOT_DIRECTION

Lights

GL_SPOT_EXPONENT

Lights

GL_SPOT_CUTOFF

Lights

GL_LIGHTi

Lights

GL_COLOR_INDEXES

Lights

Table 28.5. OpenGL State Variables: Rasterization

OpenGL State Variable

Inventor Nodes That Change This Variable

GL_POINT_SIZE

Draw Style

GL_POINT_SMOOTH

Render action

GL_LINE_WIDTH

Draw Style

GL_LINE_SMOOTH

Render Action

GL_LINE_STIPPLE_PATTERN

Draw Style

GL_LINE_STIPPLE

Draw Style

GL_CULL_FACE

Shape Hints

GL_CULL_FACE_MODE

Shape Hints

GL_POLYGON_MODE

Draw Style

GL_POLYGON_STIPPLE

Shapes if SCREEN_DOOR transparency

Table 28.6. OpenGL State Variables: Texturing

OpenGL State Variable

Inventor Nodes That Change This Variable

GL_TEXTURE_x

Texture2 node

GL_TEXTURE

Texture2 node

GL_TEXTURE_WIDTH

Texture2 node

GL_TEXTURE_HEIGHT

Texture2 node

GL_TEXTURE_COMPONENTS

Texture2 node

GL_TEXTURE_MIN_FILTER

Complexity node

GL_TEXTURE_MAG_FILTER

Complexity node

GL_TEXTURE_WRAP_x

Texture2 node

GL_TEXTURE_ENV_MODE

Texture2 node

GL_TEXTURE_ENV_COLOR

Texture2 node

GL_TEXTURE_GEN_x

Texture Coordinate Function nodes

GL_EYE_LINEAR

Texture Coordinate Function nodes

GL_OBJECT_LINEAR

Texture Coordinate Function nodes

GL_TEXTURE_GEN_MODE

Texture Coordinate Function nodes

Table 28.7. OpenGL State Variables: Pixel Operations

GL_BLEND

Render action, Texture2 node

GL_BLEND_SRC

Render action, Texture2 node

GL_BLEND_DST

Render action, Texture2 node

Table 28.8. OpenGL State Variables: Pixels

OpenGL State Variable

Inventor Nodes That Change This Variable

GL_UNPACK_ALIGNMENT

Texture2 node

GL_*_SCALE (* = RED; GREEN; BLUE; ALPHA)

Texture2 node

GL_*_BIAS (* = RED; GREEN; BLUE; ALPHA)

Texture2 node

Table 28.9. OpenGL State Variables: Miscellaneous

OpenGL State Variable

Inventor Nodes That Change This Variable

GL_LIST_BASE

Text2, Text3 nodes

GL_LIST_INDEX

Separator, Text2, Text3 nodes

GL_LIST_MODE

Separator, Text2, Text3 nodes