I am developing a 3D board game, whose pieces are painted as spheres. For that the depth buffer has to be enabled (“glEnable(GL_DEPTH_TEST);”). And there are status informations displayed during the game, which must not be covered by any game element (p. e. spheres).
I tried to achieve this effect by disabling the depth buffer while painting the status informations. But the spheres still covered the informations display, no matter if painting them before or after painting the spheres.
hey cndg, what zbuffer’s saying is that if you follow those steps, it will work. this is standard procedure for rendering game overlays (HUDs), nothing new. if you are following those steps, then there’s a mistake somewhere in your code, not in the steps. as nico said, double check your code for innocent blunders
@-NiCo-: I only use GLUT when painting the spheres. The rest of my program is “GLUT-free”. But the spheres itselves are rendered as I expect - so the depth buffer seems to be working correctly.
Is “depthMask” the property with GL_ALWAYS, GL_LESS,…? If it is: I am not changing it.
@bonehead: It was my first idea to render it that way (enable depth test - draw spheres - disable depth test - draw my status info) but it didn’t work as I told. It is so easy - what could I have done wrong? But nevertheless I am going to check my code…
I was able to solve the problem by using the stencil buffer (glStencilFunc and glStencilOp). First the stencil buffer has to be cleared with zeros. The status informations consist of letters. Where ever a letter depending to the status display is drawn the stencil buffer bits covered by the letter are replaced by ones. However the stencil test rules for spheres are a bit more restrictive. They forbid every sphere to change any bit in the stencil buffer. And they prescribe that no bit belonging to any sphere is painted where the stencil buffer bits contain ones. So the status display protects itself a hundred per cent.