Problem with faces not being obscured

Started by
3 comments, last by rick_appleton 18 years, 10 months ago
Ok so the deal is, if I load and display a complex object everything seems ok. But when I rotate the object, faces that should be at the back(facing the camera, not facing back, just covered by other polys) are showing through to the front. Back face culling and depth sorting are both on... glDepthFunc(GL_GEQUAL); glCullFace(GL_BACK); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE);
Advertisement
You want glDepthFunc(GL_LEQUAL);

According to the redbook:
Quote:
void glDepthFunc(GLenum func);
Sets the comparison function for the depth test. The value for func must be GL_NEVER,
GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, or
GL_NOTEQUAL. An incoming fragment passes the depth test if its z value has the specified
relation to the value already stored in the depth buffer. The default is GL_LESS, which means that
an incoming fragment passes the test if its z value is less than that already stored in the depth
buffer. In this case, the z value represents the distance from the object to the viewpoint, and
smaller values mean the corresponding objects are closer to the viewpoint.
Yeah I had fiddled around with that setting a bit, if its anything but GREATER(no text) or GEQUAL(shows everything) I get nothing at all. I'm using data I generate in Blender, then export to my own format containing a list of all verts and a list of faces containing indices to each vert.
Oh I'm dumb ;) Was clearing the depth buffer incorrectly anyway. No problems now. I always find the answer to my problem after I ask someone heh...
In that case you'll have to give some more information. What do you mean by GREATER(no text) or GEQUAL(shows everything)? And you're clearing the depth buffer every frame I trust?

This topic is closed to new replies.

Advertisement