Qt5OpenGL: use OpenGL debug logger to locate problems, fix a couple of errors

This commit is contained in:
wmayer
2017-03-14 00:02:37 +01:00
parent 79f961ee9c
commit 764f9ce7e5
8 changed files with 29 additions and 30 deletions

View File

@@ -125,7 +125,9 @@ void Flag::drawLine (View3DInventorViewer* v, int tox, int toy)
GLPainter p;
p.begin(v->getGLWidget());
#if !defined(HAVE_QT5_OPENGL)
p.setDrawBuffer(GL_BACK);
#endif
// the line
p.setLineWidth(1.0f);

View File

@@ -61,6 +61,7 @@ bool GLPainter::begin(QPaintDevice * device)
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, this->width, 0, this->height, -1, 1);
@@ -80,7 +81,9 @@ bool GLPainter::begin(QPaintDevice * device)
glLineWidth(1.0f);
glColor4f(1.0, 1.0, 1.0, 0.0);
glViewport(0, 0, this->width, this->height);
#if !defined(HAVE_QT5_OPENGL)
glDrawBuffer(GL_FRONT);
#endif
return true;
}
@@ -110,7 +113,6 @@ bool GLPainter::end()
glPopAttrib();
glPopMatrix();
viewer->doneCurrent();
viewer = 0;
return true;
}

View File

@@ -65,6 +65,11 @@
#include <QPaintEvent>
#include <QResizeEvent>
#if defined(HAVE_QT5_OPENGL)
#include <QOpenGLDebugMessage>
#include <QOpenGLDebugLogger>
#endif
#include <Inventor/SbViewportRegion.h>
#include <Inventor/system/gl.h>
#include <Inventor/events/SoEvents.h>
@@ -136,7 +141,7 @@ using namespace SIM::Coin3D::Quarter;
#ifndef GL_MULTISAMPLE_BIT_EXT
#define GL_MULTISAMPLE_BIT_EXT 0x20000000
#endif
//We need to avoid buffer swaping when initializing a QPainter on this widget
#if defined(HAVE_QT5_OPENGL)
class CustomGLWidget : public QOpenGLWidget {
@@ -147,9 +152,18 @@ public:
Q_UNUSED(shareWidget);
QSurfaceFormat surfaceFormat(format);
surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
// With the settings below we could determine deprecated OpenGL API
// but can't do this since otherwise it will complain about almost any
// OpenGL call in Coin3d
//surfaceFormat.setMajorVersion(3);
//surfaceFormat.setMinorVersion(2);
//surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
#if defined (_DEBUG) && 1
surfaceFormat.setOption(QSurfaceFormat::DebugContext);
#endif
setFormat(surfaceFormat);
}
};
};
#else
class CustomGLWidget : public QGLWidget {
public:
@@ -804,7 +818,8 @@ void QuarterWidget::paintEvent(QPaintEvent* event)
assert(w->isValid() && "No valid GL context found!");
#if defined(HAVE_QT5_OPENGL)
glDrawBuffer(w->format().swapBehavior() == QSurfaceFormat::DoubleBuffer ? GL_BACK : GL_FRONT);
// Causes an OpenGL error on resize
//glDrawBuffer(w->format().swapBehavior() == QSurfaceFormat::DoubleBuffer ? GL_BACK : GL_FRONT);
#else
glDrawBuffer(w->doubleBuffer() ? GL_BACK : GL_FRONT);
#endif
@@ -820,14 +835,13 @@ void QuarterWidget::paintEvent(QPaintEvent* event)
glPopAttrib();
#if defined(HAVE_QT5_OPENGL)
if (w->format().swapBehavior() == QSurfaceFormat::DoubleBuffer)
w->context()->swapBuffers(w->context()->surface());
// Causes an OpenGL error on resize
//if (w->format().swapBehavior() == QSurfaceFormat::DoubleBuffer)
// w->context()->swapBuffers(w->context()->surface());
#else
if (w->doubleBuffer()) { w->swapBuffers(); }
#endif
w->doneCurrent();
PRIVATE(this)->autoredrawenabled = true;
// process the delay queue the next time we enter this function,

View File

@@ -147,6 +147,5 @@ void Thumbnail::createThumbnailFromFramebuffer(QImage& img) const
QtGLFramebufferObject fbo(this->size, this->size, format);
this->viewer->renderToFramebuffer(&fbo);
img = fbo.toImage();
static_cast<QtGLWidget*>(this->viewer->getGLWidget())->doneCurrent();
}
}

View File

@@ -603,8 +603,6 @@ void View3DInventor::previewFromFramebuffer(const QRect& rect, QImage& img)
_viewer->setBackgroundColor(col);
_viewer->setGradientBackground(on);
img = fbo.toImage();
static_cast<QtGLWidget*>(_viewer->getGLWidget())->doneCurrent();
}
// **********************************************************************************

View File

@@ -1351,7 +1351,6 @@ void View3DInventorViewer::setRenderType(const RenderType type)
framebuffer = fbo;
}
#endif
gl->doneCurrent();
}
break;
case Image:
@@ -1405,7 +1404,7 @@ QImage View3DInventorViewer::grabFramebuffer()
res = fbo.toImage(false);
}
#endif
gl->doneCurrent();
return res;
}

View File

@@ -729,8 +729,6 @@ void View3DInventorPy::createImageFromFramebuffer(int width, int height, const Q
viewer->setBackgroundColor(col);
viewer->setGradientBackground(on);
img = fbo.toImage();
static_cast<QtGLWidget*>(viewer->getGLWidget())->doneCurrent();
}
Py::Object View3DInventorPy::saveImage(const Py::Tuple& args)

View File

@@ -97,9 +97,8 @@ GLImageBox::GLImageBox(QWidget * parent, Qt::WindowFlags f)
_pColorMap = 0;
_numMapEntries = 0;
#ifdef _DEBUG
#if defined(_DEBUG) && 0
QSurfaceFormat format;
format.setProfile(QSurfaceFormat::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
this->setFormat(format);
#endif
@@ -132,19 +131,7 @@ void GLImageBox::initializeGL()
haveMesa = (ver.find("Mesa") != std::string::npos);
}
#if _DEBUG
#if 0
QString ext = QString::fromLatin1((const char*)(glGetString(GL_EXTENSIONS)));
QStringList list = ext.split(QLatin1Char(' '));
std::list<std::string> extlist;
Q_FOREACH(QString it, list) {
extlist.push_back(it.toStdString());
}
std::string glRenderer = (const char*)(glGetString(GL_RENDERER));
std::string glVendor = (const char*)(glGetString(GL_VENDOR));
std::string glVersion = (const char*)(glGetString(GL_VERSION));
#endif
#if defined(_DEBUG) && 0
QOpenGLContext *context = QOpenGLContext::currentContext();
if (context->hasExtension(QByteArrayLiteral("GL_KHR_debug"))) {
QOpenGLDebugLogger *logger = new QOpenGLDebugLogger(this);