View Full Version : trouble with hidden surface removal
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, 03: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, 04:10 PM
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor4f(1.0f, 1.0f, 1.0f);
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......
03-13-2003, 09: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).]
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, 12: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.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.