What Hlz said ^^^^^^
OpenGL has a default state for everything, you didn’t change the matrices.
Your geometry lies in the space of xyz coodinates (-15, 0, 0) to (15, 10, 60).
Lets assume your window is square then a cube with the maximum extend would hold all geometry.
Add this in your init function:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-60.0, 60.0, -60.0, 60.0, -60.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
This will map the object space (input vertex coordinates) origin into the center of the window and the window edges are at coodinates ±60.
Your program will show all your given primitives then.
This is not perspective, farer objects don’t get smaller.
To do this try this instead of the above code:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, 1.0, 1.0, 121.0); // field of view, aspect ratio, zNear (must be > 0), far (must be > zNear)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -61.0f); // Move eye position back to have the object space origin (0,0,0) in the center of the z-range. Read the redbook!
Note that I chose the parameters to have z = 60 exactly on the zFar plane. Decrease zFar and see how your triangle gets clipped.
Play with the field of view angle parameter of gluPerspective. That’s the same as zooming with a camera.