next up previous contents
Next: 18.2.3 Per-Platform Tuning Up: 18.2.2 Store Data in Previous: 18.2.2 Store Data in

18.2.2.1 Minimizing State Changes

Your program will almost always benefit if you reduce the number of state changes. A good way to do this is to rearrange your scene data according to what state is set and render primitives with the same state settings together. Mode changes should be ordered so that the most expensive state changes occur least often. Typically it is expensive to change texture binding, material parameters, fog parameters, texture filter modes, and the lighting model. However, some experimentation will be required to determine which state settings are most expensive on your target systems. For example, on systems that accelerate rasterization, it may not be that expensive to change rasterization controls such as the depth test function and whether or not depth testing is enabled. However, if you are running on a system with software rasterization, this may cause cached graphics state, such as function pointers or automatically generated code, to be flushed and regenerated.

Your target OpenGL implementation may not optimize state changes that are redundant, so it is also important for your application to avoid setting the same state values twice, such as enabling lighting when it is already enabled.


next up previous contents
Next: 18.2.3 Per-Platform Tuning Up: 18.2.2 Store Data in Previous: 18.2.2 Store Data in
David Blythe
1999-08-06