既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)
网上有很多讲qCustomPlot启动OpenGL的文章,有些是很有用的,但也好像没有完全说清楚,现在把我觉得有用的收集起来,并加上一些自己的理解。
- 下载qCustomPlot
https://www.qcustomplot.com/
2. 下载freeglut库
由于qCustomPlot需要调用glut库里的函数,但是glut库比较老旧,而且在实际测试中,也发现一旦new了多个图表控件,当鼠标在几个窗口之间点击的时候,会互相影响,错乱,甚至崩溃的现象。freeglut库是glut的最佳替代版本,更换之后,果然解决了这个问题。
http://freeglut.sourceforge.net/index.php
我使用的是qt的mingw编译器,所以参考下面的文档
https://www.transmissionzero.co.uk/computing/using-glut-with-mingw/
3. 将"qcustomplot.h和qcustomplot.cpp"添加到自己的工程中,在qcustomplot.cpp最前面加一条头文件引用
#include "qcustomplot.h"
#include <GL/freeglut.h>
- 在qcustomplot.cpp文件中搜索 “QCPPaintBufferGlFbo::draw”,在“drawImage”之前一行加入如下代码以修复上下文错误
/\* inherits documentation from base class \*/
void QCPPaintBufferGlFbo::draw(QCPPainter \*painter) const
{
if (!painter || !painter->isActive())
{
qDebug() << Q_FUNC_INFO << "invalid or inactive painter passed";
return;
}
if (!mGlFrameBuffer)
{
qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
return;
}
//增加下面的代码
if (QOpenGLContext::currentContext() != mGlContext.data()) {
mGlContext.data()->makeCurrent(mGlContext.data()->surface());
}
painter->drawImage(0, 0, mGlFrameBuffer->toImage());
}
如果不加该行代码,运行会显示下面的问题。
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
QOpenGLFramebufferObject::bind() called from incompatible context
- 在工程.pro中添加以下内容:
在工程右键"添加库",找到libfreeglut.a库文件和头文件
**把freeglut.dll文件拷贝到exe所在目录下**,注意32位和64位库的目录有区别。
在库引用目录中添加 -lopengl32 -lglu32 否则会报如下的错误。
debug/qcustomplot.o: In function `ZN19QCPPaintBufferGlFbo5clearERK6QColor':
F:\mrzhang\Works\RecordWave\build-QtRecordWave-Desktop_Qt_5_12_4_MinGW_32_bit-Debug/../QtRecordWave/qcustomplot.cpp:937: undefined reference to `_imp__glClearColor@16'
F:\mrzhang\Works\RecordWave\build-QtRecordWave-Desktop_Qt_5_12_4_MinGW_32_bit-Debug/../QtRecordWave/qcustomplot.cpp:938: undefined reference to `_imp__glClear@4'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: \*\*\* [Makefile.Debug:105: debug/QtRecordWave.exe] Error 1
mingw32-make: \*\*\* [Makefile:38: debug] Error 2
贴下我的pro文件。
注意下面的中文注释
#-------------------------------------------------
#
# Project created by QtCreator 2022-10-15T09:59:54
#
#-------------------------------------------------
QT += core gui network opengl
#添加 opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
TARGET = QtRecordWave
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS QCUSTOMPLOT_USE_OPENGL
#添加QCUSTOMPLOT_USE_OPENGL
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT\_DISABLE\_DEPRECATED\_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0


**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新**
**需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)**
**[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618679757)**
厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新**
**需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)**
**[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618679757)**