Fedora安装OpenGL

开发OpenGL工程需要3个库文件和对应的头文件:
libglut.so,libGLU.so,libGL.so, gl.h ,glu.h, glut.h
使用locate命令可以进行定位

安装开发包(需要3个开发包):
sudo dnf install mesa-libGL-devel mesa-libGLU-devel //这两个是opengl核心库
sudo dnf install freeglut-devel //OpenGL Utility ToolKit

安装完之后用rpm命令验证安装包和查询安装的文件以及安装在什么位置(以glut-devel为例):
[root@localhost etc]# rpm -qa | grep glut
freeglut-devel-2.6.0-1.fc12.i686
[root@localhost etc]# rpm -ql freeglut-devel
/usr/include/GL/freeglut.h
/usr/include/GL/freeglut_ext.h
/usr/include/GL/freeglut_std.h
/usr/include/GL/glut.h
/usr/lib/libglut.so

测试程序:
#include<GL/glut.h>
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glOrtho(-5, 5, -5, 5, 5, 15);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0, 0);
glutWireTeapot(3);
//glutWireIcosahedron();
glFlush();
}
int main(int argc, char *argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(0, 0);
glutInitWindowSize(300, 300);
glutCreateWindow(“OpenGL 3D View”);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

fedora

fedora wrote 151 posts

Post navigation