qcustom使用OpenGL加速
qcustomplot开启opengl加速渲染,提示QOpenGLFramebufferObject::bind() called from incompatible context。
在QCPPaintBufferGlFbo::draw()前面加if(QOpenGLContext::currentContext() != mGlContext.data()) {
mGlContext.data()->makeCurrent(mGlContext.data()->surface());
}
使用setOpengl 出现这个情况:
void __cdecl QCustomPlot::setOpenGl(bool,int) QCustomPlot can’t use OpenGL because QCUSTOMPLOT_USE_OPENGL was not defined during compilation (add ‘DEFINES += QCUSTOMPLOT_USE_OPENGL’ to your qmake .pro file)
在pro文件加:Qt +=opengl
添加依赖项:
DEFINES += QCUSTOMPLOT_USE_OPENGL
如果报错不能使用glu的库,这个情况是缺少库文件:
加载qt5.x自带的OpenGL库文件:LIBS+=-lopengl32 -lglu32。
qcustom使用OpenGL加速
最新推荐文章于 2025-03-19 16:14:06 发布