日期:2014-05-16  浏览次数:20809 次

在Linux 下编译Opengl 程序

在Linux 下编译Opengl 程序

?

1. 安装 sudo apt-get install freeglut3-dev

?

?

2. 在程序

? ?里面修改

? ?加入

?

#include <stdio.h>

#include <GL/glut.h>

void myDisplay(void)

{

? ? ?glClear(GL_COLOR_BUFFER_BIT);

? ? ?glRectf(-0.5f,-0.5f,0.5f,0.5f);

? ? ?glFlush();

?}

?int main(int argc,char *argv[])

?{

? ? ?glutInit(&argc,argv);

? ? ?glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);

? ? ?glutInitWindowSize(400,400);

? ? ?glutCreateWindow("me");

? ? ?glutDisplayFunc(&myDisplay);

? ? ?glutMainLoop();

? ? ?return 0;

?}

?

?

3.编译

?

? gcc opengltest.c -o opengltest -lGL -lglut

?

4.执行

?

? ./opentest