1 #include 2 #include 3 #include 4 5 void display(); 6 7 int main( int argc, char * argv[]) { 8 glutInit(&argc, argv); 9 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 10 11 glutInitWindowPosition( 10, 10); 12 glutInitWindowSize(400, 400); 13 glutCreateWindow("hello"); 14 15 glClearColor(0.0, 0.0, 0.0, 0.0); 16 17 glMatrixMode(GL_PROJECTION); 18 glLoadIdentity(); 19 glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); 20 21 glutDisplayFunc(display); 22 23 glutMainLoop(); 24 return 0; 25 } 26 27 void display(void) { 28 glClear(GL_COLOR_BUFFER_BIT); 29 30 glColor3f(1.0, 1.0, 1.0); 31 glBegin(GL_POLYGON); 32 glVertex3f( 0.25, 0.25, 0.0); 33 glVertex3f( 0.75, 0.25, 0.0); 34 glVertex3f( 0.75, 0.75, 0.0); 35 glVertex3f( 0.25, 0.75, 0.0); 36 glEnd(); 37 glFlush(); 38 }