- 安装
源码
#include <GL/glut.h>
static 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)
{
glutInit(&argc, argv);
glutCreateWindow("OpenSource");
glutDisplayFunc(display);
glutMainLoop();
}
- 编译脚本
g++ \
opengl.c \
-o test \
-g -lglut -lm \
-L/lib/x86_64-linux-gnu -lGL