I assume it is probably different under different implementations of
OpenGL, but what happens when I enable or disable these? When should I
enable or disable them? Some say for the duration of my program, others
say only when drawing textured quads. Clearly however, if there is any
time cost to enabling or disabling it, and a cost to having it enabled
(though what that cost would be I can’t even imagine,) it would
probably depend on how often you need to enable and disable it, versus
the penalty for keeping it enabled perpetually.
I suspect there is no such penalty to keeping it on all the time, so if
the answer is as simple as that, please just let me know, thanks.
I assume it is probably different under different implementations of
OpenGL, but what happens when I enable or disable these? When should I
enable or disable them? Some say for the duration of my program, others
say only when drawing textured quads. Clearly however, if there is any
time cost to enabling or disabling it, and a cost to having it enabled
(though what that cost would be I can’t even imagine,) it would
probably depend on how often you need to enable and disable it, versus
the penalty for keeping it enabled perpetually.
Yes, there is a (very small) cost to enable it.
I suspect there is no such penalty to keeping it on all the time, so if
the answer is as simple as that, please just let me know, thanks.
Of course you can keep it on all the time if you want.
But since you asked the question, I’ll explain more in depth.
OpenGL is a state machine, which means you can set states and these will remain until you change them. For example if you set 2D texturing mode, it will stay until you want to draw solid filled triangles for example and call glDisable(GL_TEXTURE_2D) or until you want to switch to 1D/3D textures and call glEnable(GL_TEXTURE_1D/3D). The same is true for all other OpenGL attributes : colors, materials, lights, matrices…
So it’s true that GL_TEXTURE_2D has to be enabled to draw textured triangles/quads, but if the only thing you ever draw are textured triangles/quads, you can keep it enabled all the time.
Stephane