/* CS 365 Spring 2011 * Lab 1 skeleton program */ /* Notice that glut.h brings in gl.h, glu.h */ #include #include #include /* Convert degrees to radians */ #ifndef M_PI #define M_PI 3.141593 #endif #define TORAD(deg) (3.141593 * (deg) / 180.0) /* Global variables */ float eyex = 5.0; float eyey = 5.0; float eyez = 10.0; float atx = 0.0; float aty = 0.0; float atz = 0.0; /* Draw one axis, including tick marks. axno 0=x, 1=y, 2=z leng length from origin to each end of axis */ void draw_axis(int axno, int leng) { /* Your code here. */ } /* Draw all three axes */ void axes(void) { draw_axis(0, 5); draw_axis(1, 5); draw_axis(2, 5); } /* Draw an open sphere at the origin of radius r */ void sphere_open(double r) { } /* display callback */ void display() { /* Clear frame buffer */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Set up the synthetic camera in the Modelview matrix with gluLookAt() */ /* Draw axes */ axes(); glutWireTeapot(0.5); /* Then draw open sphere */ /* Make it all visible */ glFlush(); glutSwapBuffers(); } /* Special key callback */ void specialkey(int keypressed, int x, int y) { /* Need to redisplay at the end */ glutPostRedisplay(); } /* Regular key callback */ void key(unsigned char keypressed, int x, int y){ switch (keypressed) { /* e or E exits */ case 'e': case 'E': exit(0); } } /* Reshape handler */ void reshape(int w, int h){ /* Set viewport based on w and h */ /* Switch to Projection matrix */ /* Set Projection matrix using glFrustum */ /* Switch back to Modelview matrix */ /* Post a redisplay */ /* Here is a simplest imaginable version with an orthographic projection */ glViewport(0, 0, 500, 500); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glutPostRedisplay(); } /* Redraw on window maximize, etc. */ void windowstatus(int state) { if (! (state == GLUT_HIDDEN || state == GLUT_FULLY_COVERED)) glutPostRedisplay(); } /* Main program */ void main(int argc, char * argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(500, 500); glutCreateWindow("CS 365 Lab 1: MYNAME"); glutReshapeFunc(reshape); glutWindowStatusFunc(windowstatus); glutDisplayFunc(display); glutSpecialFunc(specialkey); glutKeyboardFunc(key); glEnable(GL_DEPTH_TEST); glutMainLoop(); }