glOrtho + gluPerspectve: depth problems v2.0

Hi, I’m coding a nemesis, tyrian or salamander game-like. To draw the background I set an orthographic perspective and draw a textured quad filling the entire screen. Then, I use gluPerspective() and draw the spaceships, 3D objects. Everything works fine, but I have to disable depth testing in order to see the spaceships, it’s because the background seems to have a depth of 1.0 and the spaceships 1000.0. I used gluOrtho2D() but in order to try to fix this I did glOrtho with depth parameters 1.0, 10000.0 and set the z coordinate of the quad filling the screen to 10000.0 without touching the width and height of that quad because there is no shrinking in orthographic perspective and should look the same. The problem is that the backgrounds disappears… Moreover, setting the z coord to 1.0, using glOrtho with -1.0
and 1.0 near and far parameters (or using gluOrtho2D), disabling (unfortunately) depth testing and drawing my 3D objects… depending on what object I draw the background looks fine or extremelly dark, it depends for example if I draw a glutSolidSphere, most ships but not when I draw a quad vertex per vertex or when I draw a specific ship.

I’m using MS Visual C++ 6.0, Windows XP, SDL and a GeForce 4 MX440.

Thanks.

Just disable writing to the Depth Buffer with glDepthMask(GL_FALSE) when drawing your background quad.
If you change perspective, the actual values in the Depth Buffer are not changed - just the way, they are interpreted, this can lead to strange results, if you do not know what you do.

I tryed clearing the depth buffer after drawing the quad and worked. I think that your proposal would work the same. Thank you very much.

Sorry for reposting, but I forgot that the bug of background getting darker is still here. Any ideas?

Probably you change some OpenGL states when you draw your models, but don’t set them back, when drawing the background quad for the next frame.

Try explicitly disabling lighting before drawing the Quad and set glColor(1,1,1) (or use GL_REPLACE for the quad texture instead of GL_MODULATE)

Regarding the solution to the first problem:
Both solutions have the same result, but disabling depth writing is by far the faster method, because otherwise you clear the depth buffer twice, and clearing the buffer is a rather expensive operation, compared to a state change…

Thank you to you two, mw and Overmind. Now everything’s working fine. Thanks again.