/* Demonstrates the projection concepts of distortion, letterboxing, and clipping. Displays two TeddyBears in a 2x1x1 bounding box, and defines keyboard callbacks to switch among distortion, letterboxing and clipping. Written by Caroline Geiersbach and Scott D. Anderson scott.anderson@acm.org Summer 2003 */ #include #include // for exit and atoi #include #include #include GLfloat pos[] = {16, 16, 16, 1}; // This is the proper display function void display1(void) { glClearColor(0.8,0.8,0.8,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); twCamera(); // step 1 camera twGrayLight(GL_LIGHT0, pos, 0.2, 1, 1); // step 2 lights // step 3 objects twTeddyBear(); glFlush(); glutSwapBuffers(); } // This one does the camera last void display2(void) { glClearColor(0.8,0.8,0.8,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); twGrayLight(GL_LIGHT0, pos, 0.2, 1, 1); // step 2 lights twTeddyBear(); // step 3 objects twCamera(); // step 1 camera glFlush(); glutSwapBuffers(); } // This one does the lights after the objects void display3(void) { glClearColor(0.8,0.8,0.8,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); twCamera(); // step 1 camera twTeddyBear(); // step 3 objects twGrayLight(GL_LIGHT0, pos, 0.2, 1, 1); // step 2 lights glFlush(); glutSwapBuffers(); } int main(int argc, char** argv) { int option; if( argc < 2 ) { printf("Usage: %s {1,2,3}\n1 for Normal Order (Camera, Lights, Objects)\n2 for Camera Last\n3 for Lights Last\n",argv[0]); exit(0); } else { option = atoi(argv[1]); printf("option = %d\n",option); } glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); twInitWindowSize(500,500); glutCreateWindow(argv[0]); twBoundingBox(-0.3,0.3,-0.4,0.4,-0.15,0.15); switch(option) { case 1: glutDisplayFunc(display1); break; case 2: glutDisplayFunc(display2); break; case 3: glutDisplayFunc(display3); break; } twMainInit(); glutMainLoop(); return 0; }