// Peter Bui // CSE 40166 Computer Graphics (Fall 2010) // Lab 1: simple hello, world program #include #include void display(); int main(int argc, char *argv[]) { glutInit(&argc, argv); // Initialize GLUT glutCreateWindow("hello"); // Create a window glutDisplayFunc(display); // Register display callback glutMainLoop(); // Enter main event loop return (EXIT_SUCCESS); } void display() { glClear(GL_COLOR_BUFFER_BIT); // Erase everything glColor3f(1.0, 0.0, 0.0); glBegin(GL_POLYGON); { // Define a polygon glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f( 0.5, 0.5); glVertex2f( 0.5, -0.5); } glEnd(); glColor3f(0.0, 1.0, 0.0); glBegin(GL_POLYGON); { // Define a polygon glVertex2f(-0.25, -0.25); glVertex2f(-0.25, 0.25); glVertex2f( 0.25, 0.25); glVertex2f( 0.25, -0.25); } glEnd(); glFlush(); // Flush all drawings to the screen }