From 651b3bae914b9f3c69031c97a366e5cf53ead389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 16 Jul 2020 19:54:38 +0200 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 so it 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 | 2 +- .../vtkOpenGLContextDevice2DPrivate.h | 2 +- .../External/vtkExternalOpenGLRenderWindow.cxx | 2 +- Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx | 12 ++++++------ Rendering/OpenGL2/vtkOpenGLState.cxx | 16 ++++++++-------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx b/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx index 06abb5e7e6..0d39638869 100644 --- a/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx +++ b/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx @@ -139,7 +139,7 @@ vtkIdType vtkOpenGLContextBufferId::GetPickedItem(int x, int y) // Render texture to current write buffer. Texel x,y is rendered at // pixel x,y (instead of pixel 0,0 to work around pixel ownership test). GLint savedDrawBuffer; - glGetIntegerv(GL_DRAW_BUFFER, &savedDrawBuffer); + glGetIntegerv(GL_DRAW_BUFFER0, &savedDrawBuffer); vtkOpenGLState::ScopedglEnableDisable dsaver(ostate, GL_DEPTH_TEST); vtkOpenGLState::ScopedglEnableDisable ssaver(ostate, GL_STENCIL_TEST); diff --git a/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h b/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h index 5632547459..17e2f182ef 100644 --- a/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h +++ b/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h @@ -309,7 +309,7 @@ public: this->SavedStencilTest = ostate->GetEnumState(GL_STENCIL_TEST); this->SavedBlend = ostate->GetEnumState(GL_BLEND); ostate->vtkglGetFloatv(GL_COLOR_CLEAR_VALUE, this->SavedClearColor); - ostate->vtkglGetIntegerv(GL_DRAW_BUFFER, &this->SavedDrawBuffer); + ostate->vtkglGetIntegerv(GL_DRAW_BUFFER0, &this->SavedDrawBuffer); } } diff --git a/Rendering/External/vtkExternalOpenGLRenderWindow.cxx b/Rendering/External/vtkExternalOpenGLRenderWindow.cxx index c95b50ac64..291c4e1e61 100644 --- a/Rendering/External/vtkExternalOpenGLRenderWindow.cxx +++ b/Rendering/External/vtkExternalOpenGLRenderWindow.cxx @@ -60,7 +60,7 @@ void vtkExternalOpenGLRenderWindow::Start(void) // 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 4bda9330b6..14cd43711f 100644 --- a/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx +++ b/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx @@ -533,8 +533,8 @@ bool vtkOpenGLRenderWindow::InitializeFromCurrentContext() { this->DefaultFrameBufferId = frameBufferBinding; GLint attachment = GL_COLOR_ATTACHMENT0; -#ifdef GL_DRAW_BUFFER - glGetIntegerv(GL_DRAW_BUFFER, &attachment); +#ifdef GL_DRAW_BUFFER0 + glGetIntegerv(GL_DRAW_BUFFER0, &attachment); #endif this->BackLeftBuffer = static_cast(attachment); this->FrontLeftBuffer = static_cast(attachment); @@ -660,8 +660,8 @@ bool vtkOpenGLRenderWindow::GetUsingSRGBColorSpace() 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 // GL seems odd with its handling of left/right. // if it says we are using GL_FRONT or GL_BACK @@ -716,8 +716,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 // GLES only has the GL_BACK color diff --git a/Rendering/OpenGL2/vtkOpenGLState.cxx b/Rendering/OpenGL2/vtkOpenGLState.cxx index 3822fe7bd0..dbec8329dd 100644 --- a/Rendering/OpenGL2/vtkOpenGLState.cxx +++ b/Rendering/OpenGL2/vtkOpenGLState.cxx @@ -205,8 +205,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 = this->CurrentState.DrawBinding.GetDrawBuffer(0); if (sval == GL_BACK_LEFT) { @@ -518,8 +518,8 @@ void vtkOpenGLState::vtkglBindFramebuffer(unsigned int target, unsigned int val) this->CurrentState.DrawBinding.Binding = val; this->CurrentState.DrawBinding.Framebuffer = nullptr; ::glBindFramebuffer(GL_DRAW_FRAMEBUFFER, val); -#ifdef GL_DRAW_BUFFER - ::glGetIntegerv(GL_DRAW_BUFFER, (int*)&this->CurrentState.DrawBinding.DrawBuffers[0]); +#ifdef GL_DRAW_BUFFER0 + ::glGetIntegerv(GL_DRAW_BUFFER0, (int*)&this->CurrentState.DrawBinding.DrawBuffers[0]); #endif } } @@ -1222,8 +1222,8 @@ void vtkOpenGLState::Initialize(vtkOpenGLRenderWindow*) unsigned int vals[1]; vals[0] = this->CurrentState.DrawBinding.GetDrawBuffer(0); ::glDrawBuffers(1, vals); -#ifdef GL_DRAW_BUFFER - ::glGetIntegerv(GL_DRAW_BUFFER, (int*)&this->CurrentState.DrawBinding.DrawBuffers[0]); +#ifdef GL_DRAW_BUFFER0 + ::glGetIntegerv(GL_DRAW_BUFFER0, (int*)&this->CurrentState.DrawBinding.DrawBuffers[0]); #endif ::glReadBuffer(this->CurrentState.ReadBinding.GetReadBuffer()); ::glGetIntegerv(GL_READ_BUFFER, (int*)&this->CurrentState.ReadBinding.ReadBuffer); @@ -1232,8 +1232,8 @@ void vtkOpenGLState::Initialize(vtkOpenGLRenderWindow*) void vtkOpenGLState::ResetFramebufferBindings() { ::glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (int*)&this->CurrentState.DrawBinding.Binding); -#ifdef GL_DRAW_BUFFER - ::glGetIntegerv(GL_DRAW_BUFFER, (int*)&this->CurrentState.DrawBinding.DrawBuffers[0]); +#ifdef GL_DRAW_BUFFER0 + ::glGetIntegerv(GL_DRAW_BUFFER0, (int*)&this->CurrentState.DrawBinding.DrawBuffers[0]); #endif ::glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (int*)&this->CurrentState.ReadBinding.Binding); -- 2.27.0