How Expensive are redundant State Changes?

It’s quite excessive (and almost certainly harmful) to shadow per-vertex state.

  • Matt

I’m to lasy to implement a wrapper for everything in OpenGL. Even if it is very clever and efficient to do it.

I think there’s a simple way to exploit the enum constant VALUES.

What would we need?

Just an array with the range of enum values used. (The array should be quite small, but I’m no sure about the range of enums.Jon Leech at SGI wrote something about the enum ranges once. I’ll try to find it.) The enum could be used on lookup in the array. The value of the array would be the state set.

We would need some methods in the class to fetch the state changes. At least glEnable/glDisable needs to be fetched. I would use standard names. (Is it possible to use function pointers to redirect the calls in a general method.)

And most of this could be fetched simplty by adding the object and scope-operator, to the old code. (wrapper.glEnable(GL_VERTEX_ARRAY))

Could this work?? Have I overlooked something important? Am I mad?

Vegar