Ubuntu配置OpenGL环境

创建基本编译环境ubuntu

1 sudo apt-get install build-essential

 

安装OpenGL Libraryoop

1 sudo apt-get install libgl1-mesa-dev

 

安装OpenGL Utilities测试

1 sudo apt-get install libglu1-mesa-dev

 

安装OpenGL Utility Toolkitui

1 sudo apt-get install freeglut3-dev

 

测试效果:a.cspa

 1 #include <GL/glut.h>
 2 
 3 void init()
 4 {
 5     glClearColor(0.0, 0.0, 0.0, 0.0);
 6     glMatrixMode(GL_PROJECTION);
 7     glOrtho(-5, 5, -5, 5, 5, 15);
 8     glMatrixMode(GL_MODELVIEW);
 9     gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
10 }
11 
12 void display()
13 {
14     glClear(GL_COLOR_BUFFER_BIT);
15     glColor3f(1.0, 0, 0);
16     glutWireTeapot(3);
17     glFlush();
18 }
19 
20 int main(int argc, char *argv[])
21 {
22     glutInit(&argc, argv);
23     glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
24     glutInitWindowPosition(0, 0);
25     glutInitWindowSize(300, 300);
26     glutCreateWindow("OpenGL 3D View");
27     init(); glutDisplayFunc(display);
28     glutMainLoop();
29     return 0;
30 }

 

编译code

1 gcc a.c -o a -lGL -lGLU -lglut

 

效果如图blog

ubuntu 12.04安装OpenGL

相关文章
相关标签/搜索