Performance Programming Techniques
163
Performance Programming Techniques
The following sections provide programming tips for improving the performance of
your application:
•“Minimize Use of csAppearance Fields” on page 163.
•“Minimize Use of csAppearance Modes” on page 163.
•“Indexing csGeoSet Attributes” on page 164.
•“Setting the Transformation Matrix Directly” on page 164.
•“Compiling Part of a Scene Graph” on page 164.
Minimize Use of csAppearance Fields
Many of the fields in csContext set the appearance of a geometry. The fields in
csAppearance match those in csContext. Setting a csAppearance field overrides the
values of the same fields set in csContext. Overriding csContext values, however,
reduces performance because the field has to be reevaluated every time the
csAppearance object is applied.
To maximize performance:
• Set csContext fields to values that satisfy a majority of the shapes in a scene.
• Set the inherit field in csAppearance to inherit, not apply, those fields.
In this way, you set the minimum number of csAppearance fields.
Minimize Use of csAppearance Modes
Some of the fields set in csAppearance are much more graphics-intensive than others. In
particular, the blending, texture, and lighting fields require larger amounts of CPU time.
To improve performance, it is better not to turn on these modes if your application does
not need them.