that is quite a nice bit of code I like the idea of pushing the current state and poping it once you've finished.

i might try and replicate this kind of system in opengl.