#include <GL/glut.h>
void display() //定义了所要绘制的图形实体
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, -0.5);
glVertex2f(0.5, 0.5);
glEnd();
glFlush();
}
int main(int argc, char ** argv) //OpenGL的初始化
{
glutInit(&argc, argv);
glutCreateWindow("simple");
glutDisplayFunc(display);
glutMainLoop();
}
复制别人的代码