linux 下 Qt 5.x OpenGl 下GLUT 调用
程序员文章站
2022-05-31 11:14:44
...
安装Glut
sudo apt-get install freeglut3 freeglut3-dev
sudo apt-get install binutils-gold
Qt 5.5 配置
sudo find /usr -name *glut*
结果如下:
/usr/lib/x86_64-linux-gnu/libglut.so
/usr/lib/x86_64-linux-gnu/libglut.so.3
/usr/lib/x86_64-linux-gnu/libglut.so.3.9.0
/usr/lib/x86_64-linux-gnu/libglut.a
…
..
pro文件下
LIBS += -lglut
INCLUDEPATH += -L/usr/lib/x86_64-linux-gnu/
头文件
#include <GL/glut.h>
错误提示
freeglut ERROR: Function called without first calling ‘glutInit’.
解决方法,在main中添加
glutInit( & argc, argv );
I've figured it out. It was quite simple actualy. I needed to use 'glutInit( & argc, argv )' in my main.cpp like this:
int main(int argc, char *argv[])
{
glutInit( & argc, argv );
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
引用
http://stackmirror.bird.so/page/rhln7yl4fxv4
http://blog.csdn.net/youhaipeng/article/details/8212408