Original Post
Hey all, I would like to know how state changes are handled with scene graphs. I've read this nice explanation of scene graphs. Their idea is to put OpenGL state changes into nodes of the scene graph. My question is now: Which states does such a state-change-node have to set? Of course the node has to guarantee that after execution, OpenGL is in a certain well-defined state. Since in general the node can't know in which state OpenGL currently is, the state-change-node has to set ALL states, even the ones which are not necessary to set. This would surely be ineffective. This is the model of the scene graph: state-change-node (set all states of OpenGL) --> do-something-node (draws some geometry) --> state-change-node (set all states of OpenGL) --> do-something-else-node (draws some other geometry) Another possibility is to assume that in the entry point of a state-change-node, OpenGL is already in some globally defined default state, so that the state-change-node only has to set those states which do not coincide with the default state. But that would require some kind of "destructor-state-change-node" that resets OpenGL to the default state before execution of the next state-change. This would, however, be rather ineffective if the next state-change-node sets the same states as the previous one. This is the scene graph: state-change-node (set OpenGL to a default state) --> state-change-node (only set states that are not default) --> do-something-node (draws some geometry) --> destructor-state-change-node (set OpenGL back to default again) --> state-change-node (set some other non-default states) --> do-something-else-node (draws some other geometry) --> destructor-state-change-node (set OpenGL back to default again) So how is it usually done? Lutz