File 0001-Add-missing-guard-required-for-GLES-to-disable-stere.patch of Package vtk

From b035ea7f784a842dda0c3b0dc437514879a873c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Sat, 4 Jul 2020 21:04:52 +0200
Subject: [PATCH] Add missing guard required for GLES to disable stereo
 rendering

fmt.stereo()/StereoRender will evaluate to false for GLES, guard the whole
block so GL_*_RIGHT is not used.

Change the GL_*_LEFT defines for GLES so it actually refers to a front/
back buffer, otherwise on GLES the invalid constant 0 will be used to
select the front (0x404) and back buffer (0x405). Remove GL_*_RIGHT
defines to avoid any accidental, unguarded use.
---
 GUISupport/Qt/QVTKOpenGLWindow.cxx                   | 5 +++++
 Rendering/External/vtkExternalOpenGLRenderWindow.cxx | 2 ++
 Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx          | 2 ++
 ThirdParty/glew/vtk_glew.h.in                        | 6 ++----
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/GUISupport/Qt/QVTKOpenGLWindow.cxx b/GUISupport/Qt/QVTKOpenGLWindow.cxx
index 067e27cf6e..79bd714f58 100644
--- a/GUISupport/Qt/QVTKOpenGLWindow.cxx
+++ b/GUISupport/Qt/QVTKOpenGLWindow.cxx
@@ -259,6 +259,7 @@ void QVTKOpenGLWindow::paintGL()
 
     const QSize deviceSize = this->size() * this->devicePixelRatioF();
     const auto fmt = this->context()->format();
+#ifndef GL_ES_VERSION_2_0
     if (fmt.stereo() && this->RenderWindow->GetStereoRender() &&
       this->RenderWindow->GetStereoType() == VTK_STEREO_CRYSTAL_EYES)
     {
@@ -272,6 +273,10 @@ void QVTKOpenGLWindow::paintGL()
       this->RenderWindowAdapter->blit(
         this->defaultFramebufferObject(), GL_BACK_LEFT, QRect(QPoint(0, 0), deviceSize));
     }
+#else
+    this->RenderWindowAdapter->blit(
+      this->defaultFramebufferObject(), GL_BACK, QRect(QPoint(0, 0), deviceSize));
+#endif
     ostate->Pop();
   }
   else
diff --git a/Rendering/External/vtkExternalOpenGLRenderWindow.cxx b/Rendering/External/vtkExternalOpenGLRenderWindow.cxx
index 445bfce802..d870568f99 100644
--- a/Rendering/External/vtkExternalOpenGLRenderWindow.cxx
+++ b/Rendering/External/vtkExternalOpenGLRenderWindow.cxx
@@ -64,12 +64,14 @@ void vtkExternalOpenGLRenderWindow::Start()
   for (this->GetRenderers()->InitTraversal(sit);
        (renderer = this->GetRenderers()->GetNextRenderer(sit));)
   {
+#ifndef GL_ES_VERSION_3_0
     if (bufferType == GL_BACK_RIGHT || bufferType == GL_RIGHT || bufferType == GL_FRONT_RIGHT)
     {
       this->StereoRenderOn();
       this->SetStereoTypeToRight();
     }
     else
+#endif
     {
       this->SetStereoTypeToLeft();
     }
diff --git a/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx b/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx
index 46064d3360..f5b7f6f0c3 100644
--- a/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx
+++ b/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx
@@ -1156,6 +1156,7 @@ void vtkOpenGLRenderWindow::BlitDisplayFramebuffersToHardware()
 
   ostate->vtkglBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
 
+#ifndef GL_ES_VERSION_3_0
   if (this->StereoRender && this->StereoType == VTK_STEREO_CRYSTAL_EYES)
   {
     // bind the read buffer to detach the display framebuffer to be safe
@@ -1168,6 +1169,7 @@ void vtkOpenGLRenderWindow::BlitDisplayFramebuffersToHardware()
     ostate->vtkglBlitFramebuffer(0, 0, this->Size[0], this->Size[1], 0, 0, this->Size[0],
       this->Size[1], GL_COLOR_BUFFER_BIT, GL_NEAREST);
   }
+#endif
 
   ostate->vtkglDrawBuffer(this->DoubleBuffer ? GL_BACK_LEFT : GL_FRONT_LEFT);
   // bind the read buffer to detach the display framebuffer to be safe
-- 
2.33.1

openSUSE Build Service is sponsored by