I am working with GLUT, simply trying to draw polygons in 3D and rotate the camera. I have drawn a triangle near the origin, and I can get it to display at first, without trying to implement perspective. However, as soon as I implement perspective, nothing appears on the screen.
At first I thought that the problem is the parameters of gluPerspective were incorrect, but they seem right.
In my GLUT display function, I have:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(0.0, 0.0, 0.0);
glColor3f(1.0f,0.0f,0.0f); // Red
glVertex3f( 0.0f, 0.5f, 0.0f);
glVertex3f( 0.5f,-0.5f, 0.5f);
And in my window reshape function, I have:
glViewport(0, 0, width, height);
gluPerspective(30,1,1,100); /* this line is the problem */
gluLookAt(0,0,5, 0,0,0, 0,1,0);
When I comment out the call to gluPerspective, I see my triangle fine; but when gluPerspective is called (as above), I get a blank screen.
This problem has been agonizing! Thanks in advance.