Z depth not working
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();
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement