Can someone enlighten me what the correct parameters to gluPerspective would be, for the wire cube to be visible similar to how glOrtho renders it in this example? (glOrtho works if you swap it for gluPerspective). As is, this displays a blank window.
I tried cargo-culting (a) many different values to gluPerspective, (b) different sized cubes, (c) different camera angles, (d) translating to different spots on Z; none seem to work. I didn't try adjusting glViewport, my understanding is that it's not needed for a simple example like this.
Also do I understand correctly that glOrtho, gluPerspective and glFrustum are normally mutually exclusive (they're all different ways of specifying a viewing volume) and all are equally usable with gluLookAt?
void display() {
glClearColor (1, 1, 1, 0);
glClear (GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho (0, 500, 0, 500, -100, 100);
gluPerspective (20, 1, 1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt (0, 0, 0, 0, 0, -1, 0, 1, 0); // these are the defaults
glColor3f(1, 0, 0);
glTranslatef (250, 250, 0);
glScalef (2, 2, 2);
glutWireCube (100.0);
glFlush();
}
void main (int argc, char **argv) {
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH) ;
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
int windowHandle = glutCreateWindow ("COMP 390 TME 2 Question 1");
glutSetWindow (windowHandle);
glutDisplayFunc (display);
glutMainLoop();
}