QCustomplot 2.0.1 **OpenGL ISSUES SOLVED**
I solved the issue(warnings)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (8 8 8 0)
by setting a proper number of multi-samples in setOpenGL()
. In my case setting the number of multi-samples as 8 solved the issue.
And I fixed the strange behavior when OpenGL is set for multiple QCustomPlot widgets in a single instance as follows:
When we create multiple QCustomPlot Widgets in a single instance (or single process), somehow QOpenGLContext::currentContext()
is getting other OpenGL context.
Each time when the widget has to draw, it is calling the QCPPaintBufferGlFbo::draw(QCPPainter *painter)
function. Here, the QopenGL's current context is not checked with the widget's mGLContext like in other QCPPaintBufferGlFbo class functions. So adding this check and making the mGLContext as current Context solved the issue.
Change the following function in qcustomplot.cpp
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;
}
painter->drawImage(0, 0, mGlFrameBuffer->toImage());
}
To
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());
}