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 o开发者_Go百科f 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
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);
精彩评论