Depth test problem

Im trying to draw a few things then switch to OrthoMode and draw a background. The problem is that the background hides the objects that I drew in normal mode.

I found someone having the same problem but that answer didnt help me.


http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=27634

"I think the values for z near and z far are in terms of the projection/camera’s (which specifically is one of the things i’m not sure of) z axis.

Also, with a 3D projection (this might apply to ortho too, I can see no reason why it wouldn’t in fact, but again, i’m not sure), you look down the negative Z axis, by default.

So, if the projection/camera’s z axis has a negative Z component, and you’re looking down the negative z axis, then a positive value of zfar is going to produce a negative vaule in world space coordinates, which, if your vertices are also in world space coordinates, will result in negative vertex z values being visible (all else being equal)."

I have depth test enabled in both modes. I dont use glRotate.
I do use glTranslate( 0, 0, -5) so the stuff i draw with 0.0 z coordinates will be visible, …but the background has -100 z value so it shouldnt make any difference.

I switch to ortho with:
glOrtho(0.0, 1.0, 0.0, 1.0 / mouse->getAspectRatio(), 1.0, 500.0);

The “normal mode” was set up with:
gluPerspective(perspective_angle_vert, aspect_ratio, 0.1f, 200.0f);

I am doing as follows for my skybox (drawn last):

		glDepthRange(1, 1); // This will move the sky box to the far plane, exactly
		glDepthFunc(GL_LEQUAL); // Seems to be needed, or depth value 1.0 will not be shown.

Maybe it can help you.

Thanks! It worked(glDepthRange(1, 1)) except that Im doing parralax scrolling with more layers and now it draws them according to the drawing sequence.

(“Seems to be needed” …I like theese kind of comments:)