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.