sudo dnf install mesa-libGL-devel mesa-libGLU-develsudo dnf install freeglut-devel
就齐活了。
竟然如此的简单,如此的顺利。
接下来就是运行测试程序。
1 #include<GL/glut.h> 2 3 4 void init(void) 5 { 6 glClearColor(0.0, 0.0, 0.0, 0.0); 7 glMatrixMode(GL_PROJECTION); 8 glOrtho(-5, 5, -5, 5, 5, 15); 9 glMatrixMode(GL_MODELVIEW); 10 gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0); 11 } 12 13 void display(void) 14 { 15 glClear(GL_COLOR_BUFFER_BIT); 16 glColor3f(1.0, 0, 0); 17 glutWireTeapot(3); 18 //glutWireIcosahedron(); 19 glFlush(); 20 } 21 22 int main(int argc, char *argv[]) 23 { 24 glutInit(&argc,argv); 25 glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); 26 glutInitWindowPosition(0, 0); 27 glutInitWindowSize(300, 300); 28 glutCreateWindow("OpenGL 3D View"); 29 init(); 30 glutDisplayFunc(display); 31 32 glutMainLoop(); 33 34 return 0; 35 }
然后编译
gcc -o test example.c -lGL -lGLU -lglut
运行效果如下图
开始感觉有些神奇,就这么几行代码就出来个茶壶?仔细看函数名才知道,这玩意儿早已经内置了,直接调用接口就行了。
附上一个学习的链接 参考教程
联系客服