首页 > 其他 > 详细

【三】QCustomPlot开启OpenGL绘图上下文异常问题

时间:2021-07-04 12:04:06      阅读:23      评论:0      收藏:0      [点我收藏+]

当在同一个界面中绘制多个QCustomPlot图形时,此时如果开启了OpenGL功能,则会提示QOpenGLFramebufferObject::bind() called from incompatible context的警告,界面图形渲染时会出现错乱,可以通过在qcustomplot.cpp的QCPPaintBufferGlFbo::draw()函数中添加以下红色的代码即可。

/* 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());
}

【三】QCustomPlot开启OpenGL绘图上下文异常问题

原文:https://blog.51cto.com/u_13492397/2973670

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!