Greetings!
In my scene, I draw gizmos on objects I pick in the scene (three, rgb lines). I disable depth testing when I draw them. But then I draw a grid, and want to turn on depth testing so it doesn’t overwrite pixels from the rest of the scene.
However; I always like it to be obvious immediately who’s setting/clearing the depth buffer bit, I’ve had problems where I accidentally disabled/enabled depth testing where I shouldn’t.
This is trivial to solve if I could let functions modify the depth buffer this way:
GLboolOrSomething ZState = glGetBit(GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_BUFFER_BIT);
// draw...
glEnable(GL_DEPTH_BUFFER_BIT);
// draw...
glSetBit(GL_DEPTH_BUFFER_BIT, ZState);
Then I could wrap this in two calls: BeginDepthState(NewState) (sets the new value) and EndDepthState() (reverts back to the previous value)
(I don’t necessarily need the glSetBit because I could just do if (ZState) glEnable(…) else glDisable(…) but it would be nice to have)
I know of glPushAttrib but they say it’s deprecated. I also heard of glGet but I don’t seem to have it available, I’m using core profile only functions (parsed from glcorearb.h)
Any ideas?
Thanks!
-Keithster