#include #include #ifdef __APPLE__ // include Mac OS X verions of headers #include #else // non-Mac OS X operating systems #include #endif #define XOFF 50 #define YOFF 50 #define WINDOW_WIDTH 600 #define WINDOW_HEIGHT 600 void display(void); void myinit(void); /* Function to handle file input; modification may be needed */ void file_in(void); /*----------------- The main function ------------------*/ int main(int argc, char **argv) { glutInit(&argc, argv); /* Use both double buffering and Z buffer */ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowPosition(XOFF, YOFF); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutCreateWindow("Assignment 1"); glutDisplayFunc(display); /* Function call to handle file input here */ file_in(); myinit(); glutMainLoop(); return 0; } /*---------- file_in(): file input function. Modify here. ------------*/ void file_in(void) { } /*--------------------------------------------------------------------- display(): This function is called once for _every_ frame. ---------------------------------------------------------------------*/ void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0f, 0.84f, 0.0f); /* draw in golden yellow */ glPointSize(4.0); /* size of each point */ glBegin(GL_POINTS); glVertex2i(300, 300); /* draw a vertex here */ glEnd(); glFlush(); /* render graphics */ glutSwapBuffers(); /* swap buffers */ } /*--------------------------------------------------------------------- myinit(): Set up attributes and viewing ---------------------------------------------------------------------*/ void myinit() { glClearColor(0.0f, 0.0f, 0.92f, 0.0f); /* blue background*/ /* set up viewing */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, WINDOW_WIDTH, 0.0, WINDOW_HEIGHT); glMatrixMode(GL_MODELVIEW); }