views:

31

answers:

1

I'm writing some Java OpenGL code (though the principles are the same in C++ openGL). I have a situation where I want to render certain items on top of others. I can do that by disable the depth test or by setting it to GL_ALWAYS) for those items and that works well. The issue is that colors of those items on top seem to be darkened by the items underneath it. I'm not sure if it's a lighting issue or if it's some blending issue but I'm trying to show the item's color without being affected by the colors around it, regardless of this item's z-position (since depth testing is set to ALWAYS). Is there a lighting setting or blending setting I should be using for this?

thanks, Jeff

+1  A: 

I think in this situation, I'd leave the depth settings alone, but adjust the Z value of the objects based on the drawing order (for those items you want drawn based on order instead of normal depth).

glBegin(GL_WHATEVER);
    for (int i=0; i<num_objects; i++) 
        glVertex(object[i].x, object[i].y, i/-100.0f);
glEnd(GL_WHATEVER);
Jerry Coffin
@Jerry. Thanks. In this application though, I am adding things to the surface of a globe and users can rotate the globe. If the z-values are changed, then the items won't actually be on the surface.
Jeff Storey