PDA

View Full Version : Depth test goes backwards



raijinken
07-14-2004, 01:48 AM
I`ve written a program to plot surfaces. Users can rotate the surface using the mouse. When my surface is facing front there´s no problem; but when the surface is rotated, the depth test hides what now is supposed to be near and shows what would have to be behind.

Anybody knows why could this be happenig and how can I fix it? Thanks in advance.

Relic
07-14-2004, 01:57 AM
Either you forgot to glEnable(GL_DEPTH_TEST) and the front face view just rendered back to front, then the other view direction will look like what you described, or your viewing frustum's zNear and zFar span a range too big for the depth bits resolution. In the latter case push zNear out and draw zFar in as much as you can without clipping your drawing. This is always a good idea.

raijinken
07-14-2004, 02:41 AM
I'm sure the depth test is enabled. I've tried reducing the distance from zNear to zFar as much as posible, but it doesn't work.

-NiCo-
07-14-2004, 02:50 AM
You've probably got culling enabled.
Try calling glDisable(GL_CULL_FACE) before rendering the surface.

Greetz,

Nico

raijinken
07-14-2004, 03:18 AM
It's not the cull face either. Sorry for being so tiresome, but i'm getting mad. I've been searching what can be wrong but i don't find it. I thought it could be a missing depth test activation, because there's another problem: if i draw first the axis, the surface always hides the axis, and if i draw first the surface, the axis is always drawn over the surface and never hidden.
But I'm sure the depth test is enabled (and the cull face disabled) and I don´t know what is wrong.
Thank you for your help.

Bob
07-14-2004, 04:00 AM
Do you even have a depth buffer? Try glGetIntegerv with GL_DEPTH_BITS to see how large the depth buffer is. 0 means there's no depth buffer present.

raijinken
07-14-2004, 05:54 AM
It is that!! I got 0. What have I to do to get the depth buffer?

raijinken
07-14-2004, 07:00 AM
Thank you very much. I fixed it. I'm working with a Mac OS X languaje called Cocoa and the pixel format creation is a bit different from windows. I was creating it wrong and so I didn't have the depth buffer. Thank you everybody.