2020-07-19 00:18:35 +02:00
|
|
|
From 5c4e4e5832613e758b7c1389a5dbcc1d57db7c6e Mon Sep 17 00:00:00 2001
|
2017-09-12 14:40:37 +02:00
|
|
|
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
2020-07-19 00:18:35 +02:00
|
|
|
Date: Tue, 9 Jun 2020 17:11:12 +0200
|
2017-09-12 14:40:37 +02:00
|
|
|
Subject: [PATCH] Allow compilation on GLES platforms
|
|
|
|
|
|
|
|
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
|
2020-07-19 00:18:35 +02:00
|
|
|
blitting, which in worst case (i.e. no GL_EXT_framebuffer blit
|
|
|
|
extension) is a noop, but handles all GL platform differences otherwise
|
|
|
|
(3.2 Core context, GLES 3.0, or any earlier with required extensions).
|
2017-09-12 14:40:37 +02:00
|
|
|
|
2020-07-19 00:18:35 +02:00
|
|
|
The code ignores the passed in targetId FBO handle, but relies on
|
|
|
|
the default framebuffer object of the context. As the calling code calls
|
|
|
|
QOpenGLWindow::makeCurrent() the context default FBO is the one returned
|
|
|
|
by QOpenGLWindow::defaultFramebufferObject().
|
2017-09-12 14:40:37 +02:00
|
|
|
---
|
2020-07-19 00:18:35 +02:00
|
|
|
GUISupport/Qt/QVTKRenderWindowAdapter.cxx | 21 ++++++++++++++++++++-
|
|
|
|
1 file changed, 20 insertions(+), 1 deletion(-)
|
2017-09-12 14:40:37 +02:00
|
|
|
|
2020-07-19 00:18:35 +02:00
|
|
|
diff --git a/GUISupport/Qt/QVTKRenderWindowAdapter.cxx b/GUISupport/Qt/QVTKRenderWindowAdapter.cxx
|
|
|
|
index 5a66e236df..e5fc5a6135 100644
|
|
|
|
--- a/GUISupport/Qt/QVTKRenderWindowAdapter.cxx
|
|
|
|
+++ b/GUISupport/Qt/QVTKRenderWindowAdapter.cxx
|
|
|
|
@@ -334,12 +334,17 @@ public:
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
|
|
|
QOpenGLFunctions_3_2_Core* f = this->Context->versionFunctions<QOpenGLFunctions_3_2_Core>();
|
2017-09-12 14:40:37 +02:00
|
|
|
+#else
|
2020-07-19 00:18:35 +02:00
|
|
|
+ QOpenGLFunctions* f = this->Context->functions();
|
2017-09-12 14:40:37 +02:00
|
|
|
+#endif
|
2020-07-19 00:18:35 +02:00
|
|
|
if (!f)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
|
|
|
f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetId);
|
|
|
|
f->glDrawBuffer(targetAttachment);
|
2017-09-12 14:40:37 +02:00
|
|
|
|
2020-07-19 00:18:35 +02:00
|
|
|
@@ -358,6 +363,20 @@ public:
|
|
|
|
auto sourceSize = this->FBO->size();
|
|
|
|
f->glBlitFramebuffer(0, 0, sourceSize.width(), sourceSize.height(), targetRect.x(),
|
|
|
|
targetRect.y(), targetRect.width(), targetRect.height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
2017-09-12 14:40:37 +02:00
|
|
|
+#else
|
2020-07-19 00:18:35 +02:00
|
|
|
+ GLboolean scissorTest = f->glIsEnabled(GL_SCISSOR_TEST);
|
|
|
|
+ if (scissorTest == GL_TRUE)
|
|
|
|
+ {
|
|
|
|
+ f->glDisable(GL_SCISSOR_TEST); // Scissor affects glBindFramebuffer.
|
|
|
|
+ }
|
|
|
|
+ auto sourceSize = this->FBO->size();
|
|
|
|
+ QRect sourceRect(0, 0, sourceSize.width(), sourceSize.height());
|
|
|
|
+ unsigned int readAttachment =
|
|
|
|
+ left ? this->RenderWindow->GetFrontLeftBuffer() : this->RenderWindow->GetFrontRightBuffer();
|
|
|
|
+ QOpenGLFramebufferObject::blitFramebuffer(nullptr, targetRect, this->FBO.get(), sourceRect,
|
|
|
|
+ GL_COLOR_BUFFER_BIT, GL_NEAREST, readAttachment, targetAttachment,
|
|
|
|
+ QOpenGLFramebufferObject::DontRestoreFramebufferBinding);
|
2017-09-12 14:40:37 +02:00
|
|
|
+#endif
|
|
|
|
|
2020-07-19 00:18:35 +02:00
|
|
|
this->clearAlpha(targetRect);
|
|
|
|
|
|
|
|
@@ -436,7 +455,7 @@ public:
|
|
|
|
{
|
|
|
|
Q_ASSERT(this->Context && this->FBO);
|
|
|
|
|
|
|
|
- QOpenGLFunctions_3_2_Core* f = this->Context->versionFunctions<QOpenGLFunctions_3_2_Core>();
|
|
|
|
+ QOpenGLFunctions* f = this->Context->functions();
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
// now clear alpha otherwise we end up blending the rendering with
|
2017-09-12 14:40:37 +02:00
|
|
|
--
|
2020-07-19 00:18:35 +02:00
|
|
|
2.27.0
|
2017-09-12 14:40:37 +02:00
|
|
|
|