View Full Version : Avoiding state changes

02-02-2003, 01:35 AM
I know that it is evil to enable and disable states a lot of times.
However if i, for example, donīt know wether the depth test is enabled, and i enable it a lot of times, although it has never been disabled, is this bad for performance ?

I would think that OpenGL first checks, if a state is already en-/disabled, but if not, i would have to do this.

Maybe you think itīs a stupid question, but i want to be certain about this.


02-02-2003, 01:51 AM
1. just remember if you set it on or off, then you don't have to set it x times
2. i don't think just setting alphatest on or off will slow down your program a lot. i guess it's only a variable that is set to true or false

02-02-2003, 01:55 AM
boolean glIsEnabled(GL_DEPTH_TEST)

02-02-2003, 11:37 PM
Unnecessary state changes are always bad.Make your own state checking routine instead.Put the states you use in a hashtable. Slap your own myglEnable and myglDisable calls around it. This is simple and efficient.