diff --git a/Rendering/OpenGL2/vtkOpenGLFramebufferObject.cxx b/Rendering/OpenGL2/vtkOpenGLFramebufferObject.cxx index ed58d48c2e4eb1d0f6c7abac3bec98d3f662ee2a..ba3b11f427ed76fd1fa10b91316de6d997595c73 100644 --- a/Rendering/OpenGL2/vtkOpenGLFramebufferObject.cxx +++ b/Rendering/OpenGL2/vtkOpenGLFramebufferObject.cxx @@ -605,7 +605,7 @@ void vtkOpenGLFramebufferObject::ActivateBuffers() count++; } - this->Context->GetState()->vtkDrawBuffers(count, buffers); + this->Context->GetState()->vtkDrawBuffers(count, buffers, this); delete[] buffers; } @@ -620,7 +620,7 @@ void vtkOpenGLFramebufferObject::ActivateReadBuffer( unsigned int colorAtt) { colorAtt += GL_COLOR_ATTACHMENT0; - this->Context->GetState()->vtkReadBuffer((GLenum)colorAtt); + this->Context->GetState()->vtkReadBuffer((GLenum)colorAtt, this); this->ActiveReadBuffer = colorAtt; } @@ -639,7 +639,7 @@ void vtkOpenGLFramebufferObject::ActivateDrawBuffers(unsigned int num) count++; } - this->Context->GetState()->vtkDrawBuffers(count, buffers); + this->Context->GetState()->vtkDrawBuffers(count, buffers, this); delete[] buffers; this->ActiveBuffers.clear(); @@ -674,7 +674,7 @@ void vtkOpenGLFramebufferObject::ActivateDrawBuffers(unsigned int *ids, int num) count++; } - this->Context->GetState()->vtkDrawBuffers(count, buffers); + this->Context->GetState()->vtkDrawBuffers(count, buffers, this); delete[] buffers; this->ActiveBuffers.clear(); @@ -689,14 +689,14 @@ void vtkOpenGLFramebufferObject::ActivateDrawBuffers(unsigned int *ids, int num) void vtkOpenGLFramebufferObject::DeactivateDrawBuffers() { GLenum att = GL_NONE; - this->Context->GetState()->vtkDrawBuffers(1, &att); + this->Context->GetState()->vtkDrawBuffers(1, &att, this); this->ActiveBuffers.clear(); } //---------------------------------------------------------------------------- void vtkOpenGLFramebufferObject::DeactivateReadBuffer() { - this->Context->GetState()->vtkReadBuffer(GL_NONE); + this->Context->GetState()->vtkReadBuffer(GL_NONE, this); this->ActiveReadBuffer = GL_NONE; } diff --git a/Rendering/OpenGL2/vtkOpenGLState.cxx b/Rendering/OpenGL2/vtkOpenGLState.cxx index 16cea98688a34bc216c0d20d07cf8e5fb94c2e3a..82831949679de31fee6d716fb451d6c940b1c13e 100644 --- a/Rendering/OpenGL2/vtkOpenGLState.cxx +++ b/Rendering/OpenGL2/vtkOpenGLState.cxx @@ -570,7 +570,9 @@ void vtkOpenGLState::vtkglDrawBuffer(unsigned int val) { vtkOpenGLCheckStateMacro(); - if (this->CurrentState.DrawBinding.Framebuffer && val < GL_COLOR_ATTACHMENT0) + if ((this->CurrentState.DrawBinding.Framebuffer || + this->CurrentState.DrawBinding.Binding) && val < GL_COLOR_ATTACHMENT0 + && val != GL_NONE) { // todo get rid of the && and make this always an error if FO is set vtkGenericWarningMacro( @@ -607,7 +609,9 @@ void vtkOpenGLState::vtkglDrawBuffers(unsigned int count, unsigned int *vals) return; } - if (this->CurrentState.DrawBinding.Framebuffer && vals[0] < GL_COLOR_ATTACHMENT0) + if ((this->CurrentState.DrawBinding.Framebuffer || + this->CurrentState.DrawBinding.Binding) && vals[0] < GL_COLOR_ATTACHMENT0 + && vals[0] != GL_NONE) { // todo get rid of the && and make this always an error if FO is set vtkGenericWarningMacro( @@ -653,7 +657,10 @@ void vtkOpenGLState::vtkglDrawBuffers(unsigned int count, unsigned int *vals) vtkCheckOpenGLErrorsWithStack("glDrawBuffers"); } -void vtkOpenGLState::vtkDrawBuffers(unsigned int count, unsigned int *vals) +void vtkOpenGLState::vtkDrawBuffers( + unsigned int count, + unsigned int *vals, + vtkOpenGLFramebufferObject *fo) { vtkOpenGLCheckStateMacro(); @@ -670,6 +677,12 @@ void vtkOpenGLState::vtkDrawBuffers(unsigned int count, unsigned int *vals) " be called from vtkOpenGLFramebufferObject."); } + if (fo != this->CurrentState.DrawBinding.Framebuffer) + { + vtkGenericWarningMacro( + "Attempt to set draw buffers from a Framebuffer Object that is not bound."); + } + #ifndef NO_CACHE bool changed = false; for (int i = 0; i < static_cast(count) && i < 10; ++i) @@ -696,7 +709,9 @@ void vtkOpenGLState::vtkglReadBuffer(unsigned int val) { vtkOpenGLCheckStateMacro(); - if (this->CurrentState.ReadBinding.Framebuffer && val < GL_COLOR_ATTACHMENT0) + if ((this->CurrentState.ReadBinding.Framebuffer || + this->CurrentState.ReadBinding.Binding) && val < GL_COLOR_ATTACHMENT0 + && val != GL_NONE) { vtkGenericWarningMacro( "A vtkOpenGLFramebufferObject is currently bound but a hardware draw bufer was requested."); @@ -723,7 +738,7 @@ void vtkOpenGLState::vtkglReadBuffer(unsigned int val) vtkCheckOpenGLErrorsWithStack("glReadBuffer"); } -void vtkOpenGLState::vtkReadBuffer(unsigned int val) +void vtkOpenGLState::vtkReadBuffer(unsigned int val, vtkOpenGLFramebufferObject *fo) { vtkOpenGLCheckStateMacro(); @@ -735,6 +750,12 @@ void vtkOpenGLState::vtkReadBuffer(unsigned int val) " be called from vtkOpenGLFramebufferObject."); } + if (fo != this->CurrentState.ReadBinding.Framebuffer) + { + vtkGenericWarningMacro( + "Attempt to set read buffer from a Framebuffer Object that is not bound."); + } + #ifndef NO_CACHE if (this->CurrentState.ReadBinding.ReadBuffer != val) #endif diff --git a/Rendering/OpenGL2/vtkOpenGLState.h b/Rendering/OpenGL2/vtkOpenGLState.h index e223794e7035ba2db54b1e6d7252547dd53cec43..8707bfc144775960d3f77c506983280f6722f50a 100644 --- a/Rendering/OpenGL2/vtkOpenGLState.h +++ b/Rendering/OpenGL2/vtkOpenGLState.h @@ -106,8 +106,8 @@ public: void vtkglReadBuffer(unsigned int); void vtkBindFramebuffer(unsigned int target, vtkOpenGLFramebufferObject *fo); - void vtkDrawBuffers(unsigned int n, unsigned int *); - void vtkReadBuffer(unsigned int); + void vtkDrawBuffers(unsigned int n, unsigned int *, vtkOpenGLFramebufferObject *); + void vtkReadBuffer(unsigned int, vtkOpenGLFramebufferObject *); //@} //@{ diff --git a/Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx b/Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx index 0ad6124d2e7efd2f72bb80b1fafa758abd0f27fd..71b2ea4891a1cd9665699317b9773d676b89afb3 100644 --- a/Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx +++ b/Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx @@ -1735,13 +1735,13 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::EndImageSample( if (this->Parent->ImageSampleDistance != 1.f) { this->ImageSampleFBO->DeactivateDrawBuffers(); - this->ImageSampleFBO->RestorePreviousBindingsAndBuffers( - GL_DRAW_FRAMEBUFFER); if (this->RenderPassAttached) { this->ImageSampleFBO->ActivateDrawBuffers( static_cast(this->NumImageSampleDrawBuffers)); } + this->ImageSampleFBO->RestorePreviousBindingsAndBuffers( + GL_DRAW_FRAMEBUFFER); // Render the contents of ImageSampleFBO as a quad to intermix with the // rest of the scene.