/**********************************/ /* Rotating teapot */ /* framework for the second lab */ /* press + - to rotate */ /* (C) Bedrich Benes 2004 */ /* bbenespurdue.edu */ /**********************************/ #include #include GLfloat angle; void Reshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1, 1, -1, 1, -10, 10); } void Display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1,1,1); glLoadIdentity(); glRotatef(angle,0,1,0); glutWireTeapot(0.6); glutSwapBuffers(); } void Kbd(unsigned char a, int x, int y) { switch(a) { case '+' : angle-=1;break; case '-' : angle+=1;break; case 'q': case 'Q': case 27: exit(0); } glutPostRedisplay(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(200,200); glutInitWindowSize(500,500); glutCreateWindow("Rotating teapot"); glutDisplayFunc(Display); glutReshapeFunc(Reshape); glutKeyboardFunc(Kbd); glutMainLoop(); return 0; }