Original Post
I'm writing an opengl gui, so far it only supports 2d drawing. Here's my setup Now drawStuffInWindow draws everything using winDepth as its z value for glVertex(), so that every piece of geometry drawn in a given window has the same z value. The problem is I'm getting some very strange results. Example, with my z near set to 10.0, if I have 4 windows visible, the window with a layer of 2 will have the red quad totally visible and not the textured quad. But it only happen with the third window down from the top(visible), and then if I have 5 or more windows the window's with layers 2 and 4 will display this behavior. Now I tried switching around the Z_NEAR and Z_FAR and what happens is, windows at different layers will display this behavior, so instead of window 2 and 4 it might be 3 and 1 or whatever. I'd really appreciate some help on this one, hope I've been descriptive enough. I should mention that by incrimenting the"winDepth" variable each time I draw within a window, the problem goes away, leading me to believe that it's somehow related to ogl depth buffer precision. [Edited by - ari556655 on April 7, 2010 12:29:20 AM]
#define Z_NEAR 10.0
#define Z_FAR 100.0
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
void drawStuffInWindw()
{
// each is drawn over the entire window's content area so
// the red quad should never be visible
drawRedQuadOverEntireWindow();
drawTexturedQuadOverEntireWindow();
}
//the lower the window->layer the closer it is, 0 always is the top window
void drawWindows()
{
for (i = 0; i < num windows; i++)
{
winDepth = getWindowWithLayer(i)->layer - Z_NEAR;
drawStuffInWindow();
}
}