I’m quite confused with moving a 3D camera in space… Why is it that no matter how I move the camera or where I render the triangle strip, it is clipped at either -1 or +1 from the origin?
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluLookAt(0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();glTranslatef(0.0f, 0.0f, ZDist);
glBegin(GL_TRIANGLE_STRIP);
glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-5.0f, 5.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(-5.0f, -5.0f, 0.0f);
glColor3f(0.0f, 0.0f, 1.0f); glVertex3f(5.0f, 5.0f, 0.0f);
glColor3f(0.5f, 0.0f, 0.5f); glVertex3f(5.0f, -5.0f, 0.0f);
glEnd();glutSwapBuffers();
}void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w / (GLfloat) h, 0.5, 20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}