From 59ad85c74a850736ad4fcdcb9dd00779a7fff0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sun, 21 Nov 2021 22:51:36 +0100 Subject: [PATCH 2/2] Use GL_DRAW_BUFFER0 instead of GL_DRAW_BUFFER for GLES compatibility ARB_draw_buffers is part of GL 2.0, so GL_DRAW_BUFFERS0 is always available, and contrary to GL_DRAW_BUFFER it is also valid for GLES (part of GLES 3 or as EXT_draw_buffers). This also matches the universal use of glDrawBuffers instead of glDrawBuffer. At least with MESA, GL_DRAW_BUFFER and GL_DRAW_BUFFER0 always return the same value. GL_DRAW_BUFFERn is also used in several places already. --- .../ContextOpenGL2/vtkOpenGLContextBufferId.cxx | 4 ++-- .../ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h | 4 ++-- Rendering/External/vtkExternalOpenGLRenderWindow.cxx | 2 +- Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx | 8 ++++---- Rendering/OpenGL2/vtkOpenGLState.cxx | 12 ++++++------ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx b/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx index 9b6c16d4..af9d5a11 100644 --- a/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx +++ b/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx @@ -129,8 +129,8 @@ vtkIdType vtkOpenGLContextBufferId::GetPickedItem(int x, int y) // pixel x,y (instead of pixel 0,0 to work around pixel ownership test). GLint savedDrawBuffer = GL_BACK_LEFT; -#ifdef GL_DRAW_BUFFER - glGetIntegerv(GL_DRAW_BUFFER, &savedDrawBuffer); +#ifdef GL_DRAW_BUFFER0 + glGetIntegerv(GL_DRAW_BUFFER0, &savedDrawBuffer); #endif vtkOpenGLState::ScopedglEnableDisable dsaver(ostate, GL_DEPTH_TEST); diff --git a/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h b/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h index 0bd7332f..6ac52956 100644 --- a/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h +++ b/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h @@ -306,8 +306,8 @@ public: this->SavedBlend = ostate->GetEnumState(GL_BLEND); ostate->vtkglGetFloatv(GL_COLOR_CLEAR_VALUE, this->SavedClearColor); -#ifdef GL_DRAW_BUFFER - ostate->vtkglGetIntegerv(GL_DRAW_BUFFER, &this->SavedDrawBuffer); +#ifdef GL_DRAW_BUFFER0 + ostate->vtkglGetIntegerv(GL_DRAW_BUFFER0, &this->SavedDrawBuffer); #else this->SavedDrawBuffer = GL_BACK_LEFT; #endif diff --git a/Rendering/External/vtkExternalOpenGLRenderWindow.cxx b/Rendering/External/vtkExternalOpenGLRenderWindow.cxx index 265c7338..9ad4640b 100644 --- a/Rendering/External/vtkExternalOpenGLRenderWindow.cxx +++ b/Rendering/External/vtkExternalOpenGLRenderWindow.cxx @@ -47,7 +47,7 @@ void vtkExternalOpenGLRenderWindow::Start() // For stereo, render the correct eye based on the OpenGL buffer mode GLint bufferType; - ostate->vtkglGetIntegerv(GL_DRAW_BUFFER, &bufferType); + ostate->vtkglGetIntegerv(GL_DRAW_BUFFER0, &bufferType); vtkCollectionSimpleIterator sit; vtkRenderer* renderer; for (this->GetRenderers()->InitTraversal(sit); diff --git a/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx b/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx index 394128b0..17d2004c 100644 --- a/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx +++ b/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx @@ -896,8 +896,8 @@ bool vtkOpenGLRenderWindow::GetUsingSRGBColorSpace() return this->UseSRGBColorSpace; #else GLint attachment = GL_BACK_LEFT; -#ifdef GL_DRAW_BUFFER - glGetIntegerv(GL_DRAW_BUFFER, &attachment); +#ifdef GL_DRAW_BUFFER0 + glGetIntegerv(GL_DRAW_BUFFER0, &attachment); #endif // GL seems odd with its handling of left/right. // if it says we are using GL_FRONT or GL_BACK @@ -953,8 +953,8 @@ int vtkOpenGLRenderWindow::GetColorBufferSizes(int* rgba) { this->MakeCurrent(); GLint attachment = GL_BACK_LEFT; -#ifdef GL_DRAW_BUFFER - glGetIntegerv(GL_DRAW_BUFFER, &attachment); +#ifdef GL_DRAW_BUFFER0 + glGetIntegerv(GL_DRAW_BUFFER0, &attachment); #endif #ifdef GL_ES_VERSION_3_0 // GL seems odd with its handling of left/right. diff --git a/Rendering/OpenGL2/vtkOpenGLState.cxx b/Rendering/OpenGL2/vtkOpenGLState.cxx index bdafa26e..ecef68dd 100644 --- a/Rendering/OpenGL2/vtkOpenGLState.cxx +++ b/Rendering/OpenGL2/vtkOpenGLState.cxx @@ -206,8 +206,8 @@ void vtkOpenGLState::CheckState() error = true; } unsigned int sval; -#ifdef GL_DRAW_BUFFER - ::glGetIntegerv(GL_DRAW_BUFFER, iparams); +#ifdef GL_DRAW_BUFFER0 + ::glGetIntegerv(GL_DRAW_BUFFER0, iparams); sval = cs.DrawBinding.GetDrawBuffer(0); if (sval == GL_BACK_LEFT) { @@ -495,8 +495,8 @@ void vtkOpenGLState::vtkglBindFramebuffer(unsigned int target, unsigned int val) { cs.DrawBinding.Binding = val; ::glBindFramebuffer(GL_DRAW_FRAMEBUFFER, val); -#ifdef GL_DRAW_BUFFER - ::glGetIntegerv(GL_DRAW_BUFFER, (int*)&cs.DrawBinding.DrawBuffers[0]); +#ifdef GL_DRAW_BUFFER0 + ::glGetIntegerv(GL_DRAW_BUFFER0, (int*)&cs.DrawBinding.DrawBuffers[0]); #endif } } @@ -1625,8 +1625,8 @@ void vtkOpenGLState::ResetFramebufferBindings() { auto& cs = this->Stack.top(); ::glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (int*)&cs.DrawBinding.Binding); -#ifdef GL_DRAW_BUFFER - ::glGetIntegerv(GL_DRAW_BUFFER, (int*)&cs.DrawBinding.DrawBuffers[0]); +#ifdef GL_DRAW_BUFFER0 + ::glGetIntegerv(GL_DRAW_BUFFER0, (int*)&cs.DrawBinding.DrawBuffers[0]); #endif ::glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (int*)&cs.ReadBinding.Binding); -- 2.47.1