View Full Version : Overlapping Rectangles
02-26-2008, 01:41 AM
Okay, I'm doing a project where I need three rectangles, each on a different axis, that I can spin around and view. The problem is that instead of displaying the way they would in real life, the one that's drawn last just covers the other two. I guess the problem is with depth. This is probably something simple I'm missing but it really has me stumped.
02-26-2008, 02:01 AM
Do you use pixel format which contains the depth buffer? If you are using GLUT, you need to ask for it using the GLUT_DEPTH flag. Is depth test (GL_DEPTH_TEST) enabled? It is disabled by default.
02-26-2008, 02:17 AM
When I try to glEnable(GLUT_DEPTH_TEST) the rectangles don't show up at all. The window is just filled with my clear color.
02-26-2008, 03:46 AM
I assume that you meant glEnable(GL_DEPTH_TEST), there is no such GLUT constant. Did you clear the depth buffer at start of the frame together with the color buffer?
02-26-2008, 02:51 PM
Oh and a classic caveat: If you're using orthographic projection you must use a reverse depth test that is, fragments with greater z pass.
02-27-2008, 11:32 AM
Really ? I have seen quite some caveats, but first time I hear about this one :-)
03-01-2008, 10:55 AM
Heh, OK, maybe not classic but to me it wasn't obvious in the first place.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.