View Full Version : trouble with hidden surface removal

03-12-2003, 03:44 PM
I have tried enabling the depth buffer and it doesn't work. I've tried enabling GL_CULL, and it won't compile. I want to be able to change perspective and not see stuff that I shouldn't be able to see. Any suggestions?

03-12-2003, 04:47 PM
When you say that you enable the depth buffer and it doesn't work, are you getting an error, or it doesn't seem to do anything. If it doesn't seem to do anything make sure you are calling glClear with GL_DEPTH_BUFFER_BIT ored in before each rendering pass. As for the issue with GL_CULL try enabling GL_CULL_FACE and then calling glCullFace with parameter set to the face(s) to be culled.

But first try the glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) and any other buffer bits you need to clear at the start of each scene.

03-12-2003, 05:10 PM
void Display(void)
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);


glPolygonMode(GL_FRONT, GL_FILL);

glColor4f(1.0f, 1.0f, 1.0f);



03-13-2003, 10:46 AM
The depth buffer doesn't seem to be doing anything. I tried clearing the depth buffer bit and it doesn't work. I also tried oliii's approach and it didn't work, either. I can still see right through the wall......
Thanks, though.

03-13-2003, 10:52 AM
If you're using Linux, you might not have a depth buffer by default. If you are creating your window using glut, be sure to include GLUT_DEPTH as one of the options in glutInitDisplayMode.

[This message has been edited by Deiussum (edited 03-13-2003).]

03-13-2003, 01:42 PM
Well, I can assure you the z-buffer DOES work, so it must be something in your code that breaks it.

Why dont you post the source code instead of letting us guessing what may be wrong?

03-14-2003, 01:36 AM

Just a wild guess, you set your near clip plane to 0. This makes the far/near ratio infinitely large, which destroys the depth buffer precision. If this is the case, just make your znear 0.1 or some other small (but not too small) positive value.