36
Chapter 3: Specifying the Appearance of Geometries
There is an inheritance mask in each csAppearance that specifies which appearance
values are inherited by csAppearance from csContext. csAppearance values
automatically override csContext default values on a per-shape basis, regardless of the
bit values in the inheritance mask.
State Machine
csContext maintains and manages OpenGL graphics state for the purpose of efficient
graphics pipeline state control. OpenGL is a state machine: you put it into various states
(or modes) that then remain in effect until you change them. For example, the current
color is a state variable. The Cosmo 3D context maintains two notions of state:
• Default state—is the global graphics state defined on a per-context basis and
maintained separately from the current state.
• Current state—represents the accumulation of the default state and the state set
when csAppearance nodes are encountered during a traversal.
State that is not explicitly set in a csAppearance via the appropriate csAppearance set()
methods is inherited from the default state. An inheritance mask, however, specifies
which csContext fields a shape inherits by default.
The effect of a set() method is immediate, as if you made the OpenGL calls directly. The
set() methods affect the current state but have no effect on the default state.
Inheritance Mask
Inheritance masks specify which csContext fields are inherited by csAppearance. Each
bit in the bitmask corresponds to a specific csAppearance field. All fields are inherited by
default.
Figure 3-1 demonstrates how the inheritance mask works as a result of the code in
Example 3-1.
Example 3-1 Inheritance Mask
csContext *ctx = new cscontext;
ctx->setCullFace(BACK);
ctx->setLightEnable(TRUE);
.