Problems with depth buffer.


I’ve got a problem that I’ve been struggling with for quite some time. For some reason, the depth buffer isn’t working in my program. It only draws the triangles if I have the depth function set to GL_EQUAL (or one of it’s derivatives). The OpenGL initialization code is pretty much exactly like some other projects I did, just changed to work in C++ instead of C. I’ve had a few people look at it, but none of them have been able to find the problem yet.

I’d be very grateful if someone would take a look at the rendering code

Rendering code + screenshot of output:

I took a look at it, and I’m failing to even see a problem in the screenshot. It all looks ok to me. (Then again, maybe I’m not awake yet.)

[This message has been edited by DFrey (edited 10-21-2000).]

For some reason the link didn’t work, but I’ll just throw an hypothesis.
Do you have blending enabled? If you are blending two chunk of your world with blending you need to be at GL_EQUAL or you’ll have some weird blending going and that might give nothing on screen.

I am just saying, it might not be it.

I had problems with the link too. But copying and pasting it into the broswer made it work.

[This message has been edited by DFrey (edited 10-21-2000).]

Oops. Maybe I should have been more specific. Those two triangles are supposed to be intersecting, but the blue one is just drawing right over top of the red one…

Ah, ok, now I’m awake. I see an error in your use of gluPerspective. You have placed the near plane at 0 which is definately not a good thing to do. By doing so, you have completely eliminated all z precision. In your case just try bumping up zNear to at least 1.

Sweet, it worked


Why does it lose all z precision when you have the near clipping plane set less than 1?