Sign in to follow this  
AmeNeko

Problem with faces not being obscured

Recommended Posts

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);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this