/* * orthoPerspect.cpp * * Created on: Feb 13, 2013 * Author: Debure, modified from OpenGL Programming Guide (Shreiner) */ /* viewing transformations */ #include #include void init (void){ glClearColor(0.0, 0.0, 0.0, 0.0); // default anyway glShadeModel(GL_FLAT); glMatrixMode(GL_PROJECTION); // specify which matrices are affected glLoadIdentity(); // start with a new transformation matrix // Use an orthographic view glOrtho(-2.0, 2.0, -2.0, 2.0, 2.0, 20.0); // or use a perspective view //glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); // or use a GLU implementation of perspective view // gluPerspective(60.0, 1.0, 1.5, 20.0); glMatrixMode(GL_MODELVIEW); } void display() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); /* viewing transformation */ glLoadIdentity(); gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); // first three values are camera pos // next three are camera direction // last three are up vector //glScalef(1.0, 2.0, 1.0); // double the size along the Y axis glutWireCube(1.0); glFlush(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500, 500); glutCreateWindow("Viewing Transforms"); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }