I read several OpenGL tutorials, and now I’m trying to experiment with simple examples. But, I have results which I can’t understand. Let’s look at the following example. I have a rectangle in Z=0 plane. When my camera is looking from (0.0, 0.0, 1.0) to (0.0, 0.0, 0.0) rectangle is visible. But, when looking from (0.0, 0.0, 1.1) rectangle is not visible. Why camera can’t see rectangle in front of it, when viewing from Z>1.0?
void Redraw() {
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluLookAt( 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ); // rectangle is visible
// gluLookAt( 0.0, 0.0, 1.1, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ); rectangle is not visible
glColor3f( 1.0, 0.0, 0.0 );
glBegin(GL_LINE_LOOP);
glVertex3f( 0.5, 0.5, 0.0 );
glVertex3f( 0.5, -0.5, 0.0 );
glVertex3f( -0.5, -0.5, 0.0 );
glVertex3f( -0.5, 0.5, 0.0 );
glEnd();
glFlush();
}
int main(int argc, char **argv) {
glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE );
glutInit( &argc, argv );
glutInitWindowPosition( 200, 200 );
glutInitWindowSize( 300, 300 );
glutCreateWindow( "Test" );
glutDisplayFunc( Redraw );
glutMainLoop();
return 0;
}