User's Manual

36
Chapter 3: Specifying the Appearance of Geometries
There is an inheritance mask in each csAppearance that species 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 efcient
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 stateis the global graphics state dened on a per-context basis and
maintained separately from the current state.
Current staterepresents 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, species
which csContext elds 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 elds are inherited by csAppearance. Each
bit in the bitmask corresponds to a specic csAppearance eld. All elds 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);
.