PDA

View Full Version : Problems with depth buffer.



timmie
10-20-2000, 11:17 PM
Hello.

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Rendering code + screenshot of output: http://www.geocities.com/SiliconValley/Lakes/1561/stuff.zip

DFrey
10-21-2000, 04:22 AM
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).]

Gorg
10-21-2000, 06:55 AM
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.

DFrey
10-21-2000, 07:05 AM
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).]

timmie
10-21-2000, 03:47 PM
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...

DFrey
10-21-2000, 05:54 PM
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.

timmie
10-22-2000, 02:40 PM
Sweet, it worked http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks!

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