38
Chapter 3: Specifying the Appearance of Geometries
Warning: It is critical that such a callback not alter the OpenGL state.
You can avoid altering the OpenGL state either by using csContext::set() calls or by
saving and restoring OpenGL state explicitly upon entry and exit of the callback.
What Modifies the Graphics State?
As a csDrawAction traverses the scene graph, the current state is modified when:
• Appearances a their draw methods are invoked.
• Calls users make to various set() methods in csContext invoke pre- and post-node
callbacks.
Traversal Order
The actual appearance of a csGeometry being drawn is independent of traversal order.
Only that csShape’s appearance and the default state affect the actual appearance. At no
time does Cosmo 3D depend on the traversal order of the draw action. No guarantees are
made about traversal order because the traversal order of the draw is subject to change.
Because applications cannot depend on draw traversal order to imply the state of the
context, methods to query the context for its current state are available.
csContext in Multi-threaded Programs
csContext can be used in a multi-threaded program. When makeCurrent() is called
within a given thread, that context is attached to the thread. Binding a thread to a context
allows multi-pipe or multi-window rendering in parallel using a single, shared copy of
the scene graph.
For more information about multi-threaded implementation, see Chapter 13,
“Multiprocessing.”