From 2d5a68b91f9d638aa408285d1608bc5d70060602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Fri, 1 Sep 2017 02:11:37 +0200 Subject: [PATCH] Allow compilation on GLES platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On GLES 2.0 platforms (more specifically, for Qt5 "opengl es2" builds), QOpenGLFunctions_3_2_Core does not exist. Since Qt 5.7, QOpenGlFramebufferObject has a static wrapper method for framebuffer blitting, which in worst case is a noop. Signed-off-by: Stefan BrĂ¼ns --- GUISupport/Qt/QVTKOpenGLNativeWidget.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx b/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx index a1676e8..16e255f 100644 --- a/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx +++ b/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx @@ -534,10 +534,15 @@ void QVTKOpenGLNativeWidget::paintGL() // blit from this->FBO to QOpenGLWidget's FBO. vtkQVTKOpenGLNativeWidgetDebugMacro("paintGL::blit-to-defaultFBO"); +#if QT_VERSION < 0x050700 QOpenGLFunctions_3_2_Core* f = QOpenGLContext::currentContext()->versionFunctions(); +#else + QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions(); +#endif if (f) { +#if QT_VERSION < 0x050700 vtkOpenGLState *ostate = this->RenderWindow->GetState(); f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, this->defaultFramebufferObject()); @@ -556,6 +561,13 @@ void QVTKOpenGLNativeWidget::paintGL() f->glBlitFramebuffer(0, 0, this->RenderWindow->GetSize()[0], this->RenderWindow->GetSize()[1], 0, 0, this->RenderWindow->GetSize()[0], this->RenderWindow->GetSize()[1], GL_COLOR_BUFFER_BIT, GL_NEAREST); +#else + f->glDisable(GL_SCISSOR_TEST); // Scissor affects glBindFramebuffer. + QRect rect(0, 0, this->RenderWindow->GetSize()[0], this->RenderWindow->GetSize()[1]); + QOpenGLFramebufferObject::blitFramebuffer(0 /* binds to default framebuffer */, rect, + this->FBO, rect, GL_COLOR_BUFFER_BIT, GL_NEAREST, GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT0, QOpenGLFramebufferObject::DontRestoreFramebufferBinding); +#endif // now clear alpha otherwise we end up blending the rendering with // background windows in certain cases. It happens on OsX -- 2.14.1