Z depth not working

Started by
3 comments, last by mehere101 19 years, 5 months ago
Hey, I am drawing a simple traingle, but for whatever reason the Z depth is being ignored. For example, glBegin( GL.GL_TRIANGLES ); glVertex3f( -0.5f, 0f, 0.005f ); glVertex3f( -0.5f, 0.5f, 0.005f ); glVertex3f( -0.5f, -0.5f, 0.005f ); glEnd(); displays the same as if I entered, glBegin( GL.GL_TRIANGLES ); glVertex3f( -0.5, 0, 0 ); glVertex3f( -0.5, 0.5, 0 ); glVertex3f( -0.5, -0.5, 0 ); glEnd();
Advertisement
The difference in z values are so small that the computer will show no difference, or a difference of a few pixels...Make the change in z bigger.
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
I tried that, and in the mean time I found out what the problem is. The problem is now stated that a short distance away from the camera there is a black plane being rendered.
You probably using ortho projection, that's why there is no perspective. And the "black plane being rendered" is probably the far clipping plane.

Just set the projection to perspective mode.The easiest way to do this is:

glMatrixMode(GL_PROJECTION);
gluPerspective(fov,(float)width/height,0.2,1000.0);

fov is the field of view(example=45.0)
width,height the dimensions of the viewport
0.2 and 1000.0 the near/far planes.

Thanks, that worked. I thought it had something to do with perspective but I wasn't sure were to begin searching (so many commands, so little time...)

This topic is closed to new replies.

Advertisement