PDA

View Full Version : Depth Test Problem



Chris Brown
04-30-2001, 12:45 AM
I am currently having a problem with depth testing using OpenGL. The problem is as follows:

A file is read into my program containing vertex, face, normal, texture and color info.

A frustrum is applied using:

gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.0f,500.0f)

Depth testing is enabled as follows:

glClearDepth(1.0f);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);

Back face culling is applied:

glCullFace(GL_FRONT);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);


glClear is used to clear the depth buffer:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

When the model is displayed iin the viewport, if the poly count is quite high, then the depth testing doesn't work.

I've proved that it's not a back face cull problem since if I do a sphere, the opposing face is culled and therefore eliminates the depth test problem. If I do a complex shape such as a torus knot or a full creature model, then the depth testing just doesn't work.

Any help would be appreciated.

chrisATI
04-30-2001, 09:28 AM
Try setting your near clip plane to be some small non-zero number such as 0.1f