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
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.
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.