1 #include <GL/glut.h>
2 void myDisplay(void)
3 {
4 glClear(GL_COLOR_BUFFER_BIT);
5 glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
6 glFlush();
7 }
8
9 int main(int argc, char *argv[])
10 {
11 glutInit(&argc, argv);
12 glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
13 glutInitWindowPosition(100, 100);
14 glutInitWindowSize(400, 400);
15 glutCreateWindow("第一个OpenGL程序");
16 glutDisplayFunc(&myDisplay);
17 glutMainLoop();
18 return 0;
19 }