QCustomPlot 使用 OpenGL 开启OpenGL加速
1.官网下载 freeglut
freeglut Windows Development Libraries (transmissionzero.co.uk)
根据需要下载
2.解压出来
3.环境配置
我的是MinGW环境配置(32位版本):
把 \bin\freeglut.dll 放在 D:\software\Qt\Qt5.12.2\5.12.2\mingw73_32\bin 下
把 \include\GL 放在 D:\software\Qt\Qt5.12.2\5.12.2\mingw73_32\include 下
把 \lib\freeglut.lib 放在 D:\software\Qt\Qt5.12.2\5.12.2\mingw73_32\lib下
4.配置Qt
在 .pro 中加入:
QT += opengl
DEFINES += QCUSTOMPLOT_USE_OPENGL
LIBS += -LD:/software/Qt/Qt5.12.2/5.12.2/mingw73_32/lib -lfreeglut -lopengl32
加入头文件
#include <GL/glut.h>
#include <GL/freeglut.h>
5.测试
调用初始化函数
glutInit(&argc, argv);
调用测试函数
ui->m_pCustomplot->setOpenGl(true);
qDebug() <<"Is start opengl?=" << ui->m_pCustomplot->openGl();
打印 true 就是成功的