Jump to content
  • Advertisement
Sign in to follow this  
mehere101

Z depth not working

This topic is 5101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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();

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!