OpenGL State

Started by sprite, July 25, 2003, 05:08:20

Previous topic - Next topic

sprite

Hello,

I am relatively new to the OpenGL scene.  Recently I have implemented an object oriented system, but I've run into a very basic problem - when objects change the openGL state (by enabling or disabling settings like texturing, culling, materials, etc) the state remains changed for all other objects.  I know you can glLoadIdentity (along with push and pop) to reset the projection and modelview matrices in openGL, so I have no problem there, but is there any way to reset the openGL state ?

Can someone tell me how this is done in large projects involving many objects that are rendered through OpenGL ?

Sorry for such a newbie question, hehe  :oops:
sprite

elias

It is generally believed that you must render objects with the state, that is transform, texture, lighting etc together. To achieve this you either have to:


1. Create a scene graph of some sort that sorts objects after state. This is what Java3D and Xith3D does. The latter is a lwjgl/jogl replacement of Java3D by David Yazel.
2. Track the state (e.g. the current texture) yourself, and change it whenever needed.
3. Use push/popClientAttrib and push/popAttrib. They work like push/popMatrix, but on GL state instead. They are probably not very performance friendly however.

BTW, if you need answers to general OpenGL questions, opengl.org has some very resourceful forums, both for newbies and advanced users.

- elias

sprite

Thanks for the info : )

Quote from: "elias"BTW, if you need answers to general OpenGL questions, opengl.org has some very resourceful forums, both for newbies and advanced users.

Oh, right.  Sorry about that - this isn't really the place to ask such things.  Thanks for pointing me to the right forum !

sprite