[visionegg] GL state responsibility (warning: may contain theory)

Hi!

I've stumbled onto a somewhat subtle bug, but I'm not sure if it's a VisionEgg responsibility or a Tony-Did-Something-Silly responsibility :). From what I've read about OpenGL / game programming, it should be the responsibility of an object being drawn to ensure that GL is in a proper state. This is where the bug popped up.

I made my own Viewport class that (will eventually) do the proper mapping from environment onto the rear-projection dome we have in the lab. In this process, I did:

glEnable(GL_TEXTURE_GEN_S)
glEnable(GL_TEXTURE_GEN_T)
glEnable(GL_TEXTURE_GEN_R)

along with the associated calls to generate the texture coordinates from a normal map (more detail than necessary...). Essentially, I turned on texture coordinate generation, and forgot to turn it off.

Later on, I made a VisionEgg.Text.Text object, and put it in a standard viewport that was drawn much later on after my custom one had been drawn. This refused to render at all because it provided its own texture coordinates while coordinate generation was still turned on.

Now comes the question. Is it my responsibility to make sure I turn off things I turn on, or is it the Text (or TextureStimulus?) object's responsibility to ensure that the system is in a state it cah properly use? I think most objects do a pretty good effort in ensuring that the system is in a state it can use (e.g. calling glLoadIdentity() before trying to set position information), but I'm not sure how far that needs to / can be pushed.

Tony

======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: