Well. It seems that the problem refers to the new and far planes of the function gluPerspective().
USe from the following function as an example:
gluPerspective( 54.0f, (GLfloat)width/(GLfloat)height, 0.1, 1000 );
Maybe the far plane in your program has been set to a small value.
-Ehsan-
Originally posted by Terminatore3:
I didn’t have this problem until I started to swap from ortho to perspective for a health bar.
Now i understand…
1.Draw your home with the perspective view. Draw your health bar with the orthographic view.
2.When you want to change the definitions of the projection matrix, you should use from the function glLoadIdentity().
So you can use from the following code:
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective();
glMatrixMode( GL_MODELVIEW );
glLoadIdentity(); //optional
<Do your transformations and draw your home, your trees>
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho();
glMatrixMode( GL_MODELVIEW );
glLoadIdentity(); //optional
<Do your transformations and draw the health bar>
OK. it seems that your problem refers to the znear plane in the function gluPerspective(). 0.001 is too small and is near to 0. never set the znear plane to very small values. 0.1 is suitable.
hope this helps.
-Ehsan-