Commit 4242f492 authored by Ken Martin's avatar Ken Martin Committed by Kitware Robot

Merge topic 'cleanup_framebuffer'

f47a1c98 Cleanup the framebuffer class
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Allison Vacanti's avatarAllison Vacanti <allison.vacanti@kitware.com>
Merge-request: !4973
parents d304a797 f47a1c98
......@@ -448,7 +448,7 @@ int vtkImageDataLIC2D::RequestData(
drawFbo->SetContext(this->Context);
drawFbo->SaveCurrentBindings();
drawFbo->Bind(GL_FRAMEBUFFER);
drawFbo->AddColorAttachment(GL_FRAMEBUFFER, 0U, magVectorTex);
drawFbo->AddColorAttachment(0U, magVectorTex);
drawFbo->ActivateDrawBuffer(0U);
//drawFbo->AddColorAttachment(vtkgl::FRAMEBUFFER_EXT, 0U, vectorTex);
//drawFbo->ActivateReadBuffer(0U);
......
......@@ -275,14 +275,14 @@ public:
vtkOpenGLState *ostate = fbo->GetContext()->GetState();
//attach
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 0U, this->LICTexture0);
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 1U, this->SeedTexture0);
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 2U, this->LICTexture1);
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 3U, this->SeedTexture1);
fbo->AddColorAttachment(0U, this->LICTexture0);
fbo->AddColorAttachment(1U, this->SeedTexture0);
fbo->AddColorAttachment(2U, this->LICTexture1);
fbo->AddColorAttachment(3U, this->SeedTexture1);
unsigned int num = 4U;
if (clearEETex)
{
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 4U, this->EETexture);
fbo->AddColorAttachment(4U, this->EETexture);
num = 5U;
}
fbo->ActivateDrawBuffers(num);
......@@ -311,9 +311,7 @@ public:
ostate->vtkglClear(GL_COLOR_BUFFER_BIT);
}
ostate->vtkglDisable(GL_SCISSOR_TEST);
// detach
// detach
fbo->RemoveTexColorAttachments(GL_DRAW_FRAMEBUFFER, num);
fbo->RemoveColorAttachments(num);
fbo->DeactivateDrawBuffers();
}
......@@ -328,7 +326,7 @@ public:
vtkOpenGLState *ostate = fbo->GetContext()->GetState();
//attach
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 0U, tex);
fbo->AddColorAttachment(0U, tex);
fbo->ActivateDrawBuffers(1);
DEBUG3CheckFrameBufferStatusMacro(GL_DRAW_FRAMEBUFFER);
......@@ -356,7 +354,7 @@ public:
}
ostate->vtkglDisable(GL_SCISSOR_TEST);
// detach
fbo->RemoveTexColorAttachments(GL_DRAW_FRAMEBUFFER, 1);
fbo->RemoveColorAttachments(1);
fbo->DeactivateDrawBuffers();
}
......@@ -953,8 +951,7 @@ void StreamingFindMinMax(
{
size_t nExtents = extents.size();
// initiate download of each region
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 0U, tex);
fbo->AddColorAttachment(GL_READ_FRAMEBUFFER, 0U, tex);
fbo->AddColorAttachment(0U, tex);
fbo->ActivateDrawBuffer(0U);
fbo->ActivateReadBuffer(0U);
fbo->CheckFrameBufferStatus(GL_FRAMEBUFFER);
......@@ -970,8 +967,8 @@ void StreamingFindMinMax(
}
fbo->DeactivateDrawBuffers();
fbo->DeactivateReadBuffer();
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 0U);
fbo->RemoveTexColorAttachment(GL_READ_FRAMEBUFFER, 0U);
fbo->RemoveColorAttachment(0U);
fbo->RemoveColorAttachment(0U);
// search each region
for (size_t q=0; q<nExtents; ++q)
{
......
......@@ -512,7 +512,7 @@ int vtkStructuredGridLIC2D::RequestData(
vtkOpenGLFramebufferObject *fbo = vtkOpenGLFramebufferObject::New();
fbo->SetContext(renWin);
fbo->Bind();
fbo->AddColorAttachment(fbo->GetBothMode(), 0,vector2);
fbo->AddColorAttachment(0, vector2);
fbo->ActivateDrawBuffer(0);
fbo->ActivateReadBuffer(0);
......
......@@ -58,8 +58,8 @@ void vtkSurfaceLICHelper::StreamingFindMinMax(
GL_FLOAT,
GL_RGBA);
}
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 0U);
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 1U);
fbo->RemoveColorAttachment(0U);
fbo->RemoveColorAttachment(1U);
fbo->DeactivateDrawBuffers();
fbo->DeactivateReadBuffer();
// map search and release each region
......
......@@ -195,10 +195,10 @@ void vtkSurfaceLICInterface::PrepareForGeometry()
vtkOpenGLFramebufferObject *fbo = this->Internals->FBO;
fbo->SaveCurrentBindings();
fbo->Bind(GL_FRAMEBUFFER);
fbo->AddDepthAttachment(GL_DRAW_FRAMEBUFFER, this->Internals->DepthImage);
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 0U, this->Internals->GeometryImage);
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 1U, this->Internals->VectorImage);
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 2U, this->Internals->MaskVectorImage);
fbo->AddDepthAttachment(this->Internals->DepthImage);
fbo->AddColorAttachment(0U, this->Internals->GeometryImage);
fbo->AddColorAttachment(1U, this->Internals->VectorImage);
fbo->AddColorAttachment(2U, this->Internals->MaskVectorImage);
fbo->ActivateDrawBuffers(3);
vtkCheckFrameBufferStatusMacro(GL_FRAMEBUFFER);
......@@ -215,10 +215,10 @@ void vtkSurfaceLICInterface::PrepareForGeometry()
void vtkSurfaceLICInterface::CompletedGeometry()
{
vtkOpenGLFramebufferObject *fbo = this->Internals->FBO;
fbo->RemoveRenDepthAttachment(GL_DRAW_FRAMEBUFFER);
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 0U);
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 1U);
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 2U);
fbo->RemoveDepthAttachment();
fbo->RemoveColorAttachment(0U);
fbo->RemoveColorAttachment(1U);
fbo->RemoveColorAttachment(2U);
fbo->DeactivateDrawBuffers();
fbo->UnBind(GL_FRAMEBUFFER);
......@@ -508,8 +508,8 @@ void vtkSurfaceLICInterface::CombineColorsAndLIC()
fbo->SaveCurrentBindings();
fbo->Bind(GL_FRAMEBUFFER);
fbo->InitializeViewport(this->Internals->Viewsize[0], this->Internals->Viewsize[1]);
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 0U, this->Internals->RGBColorImage);
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 1U, this->Internals->HSLColorImage);
fbo->AddColorAttachment(0U, this->Internals->RGBColorImage);
fbo->AddColorAttachment(1U, this->Internals->HSLColorImage);
fbo->ActivateDrawBuffers(2U);
vtkCheckFrameBufferStatusMacro(GL_FRAMEBUFFER);
......@@ -612,7 +612,7 @@ void vtkSurfaceLICInterface::CombineColorsAndLIC()
LMaxMinDiff = LMax-LMin;
// normalize shader
fbo->AddColorAttachment(GL_DRAW_FRAMEBUFFER, 0U, this->Internals->RGBColorImage);
fbo->AddColorAttachment(0U, this->Internals->RGBColorImage);
fbo->ActivateDrawBuffer(0U);
vtkCheckFrameBufferStatusMacro(GL_DRAW_FRAMEBUFFER);
......@@ -646,13 +646,13 @@ void vtkSurfaceLICInterface::CombineColorsAndLIC()
this->Internals->HSLColorImage->Deactivate();
this->Internals->LICImage->Deactivate();
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 0U);
fbo->RemoveColorAttachment(0U);
fbo->DeactivateDrawBuffers();
}
else
{
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 0U);
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 1U);
fbo->RemoveColorAttachment(0U);
fbo->RemoveColorAttachment(1U);
fbo->DeactivateDrawBuffers();
}
......
......@@ -119,16 +119,15 @@ void vtkDepthImageProcessingPass::RenderDelegate(const vtkRenderState *s,
}
s2.SetFrameBuffer(fbo);
fbo->AddColorAttachment(
fbo->GetDrawMode(), 0,colortarget);
fbo->Bind();
fbo->AddColorAttachment(0, colortarget);
// because the same FBO can be used in another pass but with several color
// buffers, force this pass to use 1, to avoid side effects from the
// render of the previous frame.
fbo->ActivateDrawBuffer(0);
fbo->AddDepthAttachment(fbo->GetDrawMode(), depthtarget);
fbo->AddDepthAttachment(depthtarget);
fbo->StartNonOrtho(newWidth, newHeight);
// 2. Delegate render in FBO
......
......@@ -278,8 +278,7 @@ void vtkDepthPeelingPass::BlendIntermediatePeels(
this->State->vtkglDisable(GL_DEPTH_TEST);
this->Framebuffer->AddColorAttachment(
this->Framebuffer->GetBothMode(), 0,
this->Framebuffer->AddColorAttachment(0,
this->TranslucentRGBATexture[this->ColorDrawCount % 3]);
this->ColorDrawCount++;
......@@ -315,8 +314,7 @@ void vtkDepthPeelingPass::BlendFinalPeel(vtkOpenGLRenderWindow *renWin)
this->FinalBlend->Program->SetUniformi(
"opaqueZTexture", this->OpaqueZTexture->GetTextureUnit());
this->Framebuffer->AddColorAttachment(
this->Framebuffer->GetBothMode(), 0,
this->Framebuffer->AddColorAttachment(0,
this->TranslucentRGBATexture[this->ColorDrawCount % 3]);
this->ColorDrawCount++;
......@@ -466,10 +464,8 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
}
this->Framebuffer->SaveCurrentBindingsAndBuffers();
this->Framebuffer->Bind();
this->Framebuffer->AddDepthAttachment(
this->Framebuffer->GetBothMode(), this->TranslucentZTexture[0]);
this->Framebuffer->AddColorAttachment(
this->Framebuffer->GetBothMode(), 0,
this->Framebuffer->AddDepthAttachment(this->TranslucentZTexture[0]);
this->Framebuffer->AddColorAttachment(0,
this->TranslucentRGBATexture[0]);
this->State->vtkglViewport(0, 0,
......@@ -485,9 +481,7 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
this->State->vtkglClearDepth(static_cast<GLclampf>(1.0));
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
this->Framebuffer->AddDepthAttachment(
this->Framebuffer->GetBothMode(),
this->TranslucentZTexture[1]);
this->Framebuffer->AddDepthAttachment(this->TranslucentZTexture[1]);
this->State->vtkglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#ifdef GL_MULTISAMPLE
......@@ -542,8 +536,7 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
this->State->vtkglDepthMask(GL_TRUE);
this->State->vtkglEnable(GL_DEPTH_TEST);
this->Framebuffer->AddColorAttachment(
this->Framebuffer->GetBothMode(), 0,
this->Framebuffer->AddColorAttachment(0,
this->TranslucentRGBATexture[this->ColorDrawCount % 3]);
this->ColorDrawCount++;
......@@ -584,15 +577,13 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
if (this->PeelCount % 2)
{
this->TranslucentZTexture[0]->Deactivate();
this->Framebuffer->AddDepthAttachment(
this->Framebuffer->GetBothMode(), this->TranslucentZTexture[0]);
this->Framebuffer->AddDepthAttachment(this->TranslucentZTexture[0]);
this->TranslucentZTexture[1]->Activate();
}
else
{
this->TranslucentZTexture[1]->Deactivate();
this->Framebuffer->AddDepthAttachment(
this->Framebuffer->GetBothMode(), this->TranslucentZTexture[1]);
this->Framebuffer->AddDepthAttachment(this->TranslucentZTexture[1]);
this->TranslucentZTexture[0]->Activate();
}
......
......@@ -1066,8 +1066,7 @@ void vtkDualDepthPeelingPass::ActivateDrawBuffers(const TextureName *ids,
this->Framebuffer->DeactivateDrawBuffers();
for (size_t i = 0; i < numTex; ++i)
{
this->Framebuffer->AddColorAttachment(GL_DRAW_FRAMEBUFFER,
static_cast<unsigned int>(i),
this->Framebuffer->AddColorAttachment(static_cast<unsigned int>(i),
this->Textures[ids[i]]);
}
......
......@@ -202,11 +202,9 @@ void vtkEDLShading::EDLInitializeFramebuffers(vtkRenderState &s)
// Apply textures
// to make things clear, we write all
this->ProjectionFBO->AddColorAttachment(
this->ProjectionFBO->GetBothMode(), 0, this->ProjectionColorTexture);
this->ProjectionFBO->AddColorAttachment(0, this->ProjectionColorTexture);
this->ProjectionFBO->ActivateDrawBuffer(0);
this->ProjectionFBO->AddDepthAttachment(
this->ProjectionFBO->GetBothMode(), this->ProjectionDepthTexture);
this->ProjectionFBO->AddDepthAttachment(this->ProjectionDepthTexture);
this->ProjectionDepthTexture->SetWrapS(vtkTextureObject::ClampToEdge);
this->ProjectionDepthTexture->SetWrapT(vtkTextureObject::ClampToEdge);
......@@ -240,10 +238,9 @@ void vtkEDLShading::EDLInitializeFramebuffers(vtkRenderState &s)
}
this->EDLHighFBO->SaveCurrentBindingsAndBuffers();
this->EDLHighFBO->Bind();
this->EDLHighFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLHighShadeTexture);
this->EDLHighFBO->AddColorAttachment(0, this->EDLHighShadeTexture);
this->EDLHighFBO->ActivateDrawBuffer(0);
this->EDLHighFBO->AddDepthAttachment(GL_DRAW_FRAMEBUFFER);
this->EDLHighFBO->AddDepthAttachment();
this->EDLHighFBO->UnBind();
this->EDLHighFBO->RestorePreviousBindingsAndBuffers();
......@@ -283,10 +280,9 @@ void vtkEDLShading::EDLInitializeFramebuffers(vtkRenderState &s)
}
this->EDLLowFBO->SaveCurrentBindingsAndBuffers();
this->EDLLowFBO->Bind();
this->EDLLowFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLLowShadeTexture);
this->EDLLowFBO->AddColorAttachment(0, this->EDLLowShadeTexture);
this->EDLLowFBO->ActivateDrawBuffer(0);
this->EDLLowFBO->AddDepthAttachment(GL_DRAW_FRAMEBUFFER);
this->EDLLowFBO->AddDepthAttachment();
this->EDLLowShadeTexture->SetWrapS(vtkTextureObject::ClampToEdge);
this->EDLLowShadeTexture->SetWrapT(vtkTextureObject::ClampToEdge);
......@@ -381,8 +377,8 @@ bool vtkEDLShading::EDLShadeHigh(
s.SetFrameBuffer(this->EDLHighFBO);
this->EDLHighShadeTexture->Activate();
this->EDLHighFBO->SaveCurrentBindingsAndBuffers();
this->EDLHighFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLHighShadeTexture);
this->EDLHighFBO->Bind();
this->EDLHighFBO->AddColorAttachment(0, this->EDLHighShadeTexture);
this->EDLHighFBO->ActivateDrawBuffer(0);
this->EDLHighFBO->Start(this->W, this->H);
......@@ -473,8 +469,8 @@ bool vtkEDLShading::EDLShadeLow(
this->EDLLowShadeTexture->SetLinearMagnification(true);
this->EDLLowShadeTexture->SendParameters();
this->EDLLowFBO->SaveCurrentBindingsAndBuffers();
this->EDLLowFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLLowShadeTexture);
this->EDLLowFBO->Bind();
this->EDLLowFBO->AddColorAttachment(0, this->EDLLowShadeTexture);
this->EDLLowFBO->ActivateDrawBuffer(0);
this->EDLLowFBO->Start(this->W / this->EDLLowResFactor,
this->H / this->EDLLowResFactor);
......@@ -532,8 +528,8 @@ bool vtkEDLShading::EDLBlurLow(vtkRenderState &s,
s.SetFrameBuffer(this->EDLLowFBO);
this->EDLLowBlurTexture->Activate();
this->EDLLowFBO->SaveCurrentBindingsAndBuffers();
this->EDLLowFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLLowBlurTexture);
this->EDLLowFBO->Bind();
this->EDLLowFBO->AddColorAttachment(0, this->EDLLowBlurTexture);
this->EDLLowFBO->ActivateDrawBuffer(0);
this->EDLLowFBO->Start(this->W / EDLLowResFactor, this->H / EDLLowResFactor);
......
......@@ -189,8 +189,7 @@ void vtkGaussianBlurPass::Render(const vtkRenderState *s)
VTK_UNSIGNED_CHAR,false);
}
this->FrameBufferObject->AddColorAttachment(
this->FrameBufferObject->GetBothMode(), 0,this->Pass2);
this->FrameBufferObject->AddColorAttachment(0,this->Pass2);
this->FrameBufferObject->Start(w, h);
#ifdef VTK_GAUSSIAN_BLUR_PASS_DEBUG
......
......@@ -157,15 +157,15 @@ void vtkImageProcessingPass::RenderDelegate(const vtkRenderState *s,
target->Create2D(newWidth,newHeight,4,VTK_UNSIGNED_CHAR,false);
}
fbo->AddColorAttachment(
fbo->GetBothMode(), 0, target);
fbo->Bind();
fbo->AddColorAttachment(0, target);
// because the same FBO can be used in another pass but with several color
// buffers, force this pass to use 1, to avoid side effects from the
// render of the previous frame.
fbo->ActivateBuffer(0);
fbo->AddDepthAttachment(fbo->GetBothMode());
fbo->AddDepthAttachment();
fbo->StartNonOrtho(newWidth,newHeight);
ostate->vtkglViewport(0, 0, newWidth, newHeight);
ostate->vtkglScissor(0, 0, newWidth, newHeight);
......
......@@ -46,8 +46,7 @@
* have draw and read framebuffer objects (bindings) and then for the currently
* bound FramebufferObjects you have active draw and read buffers.
*
* A single FramebufferObject can be bound to both Draw and Read. Likewise
* a single buffer can be activated for both draw and read operations. You
* A single FramebufferObject can be bound to both Draw and Read. You
* cannot assign and activate a TextureObject for drawing on the FO and
* at the same time pass it in as a Texture to the shader program. That
* type of operation is very common and must be done in two steps.
......@@ -61,7 +60,6 @@
* fbo->SetContext(renWin);
* fbo->SaveCurrentBindingsAndBuffers();
* fbo->PopulateFramebuffer(width, height);
* fbo->Start();
*
* ...
*
......@@ -77,7 +75,6 @@
* fbo->AddColorAttachment(0, vtkTextureObj);
* fbo->AddDepthAttachment(); // auto create depth buffer
* fbo->ActivateBuffer(0);
* fbo->Start();
*
* ...
*
......@@ -92,7 +89,6 @@
* // setup the FBO once
* fbo->SetContext(renWin);
* fbo->SaveCurrentBindingsAndBuffers();
* fbo->Bind();
* fbo->AddColorAttachment(0, vtkTextureObj);
* fbo->AddDepthAttachment(); // auto create depth buffer
* fbo->RestorePreviousBindingsAndBuffers();
......@@ -101,13 +97,12 @@
* fbo->SaveCurrentBindingsAndBuffers();
* fbo->Bind();
* fbo->ActivateBuffer(0);
* fbo->Start();
* ... // render here etc
* fbo->RestorePreviousBindingsAndBuffers();
*\endcode
*
* If you with to only bind/attach the draw buffers or read buffers there
* are mode specific versions of most methods that only apply to the
* If you with to only bind the framebuffer for drawing or reading there
* are mode specific versions of some methods that only apply to the
* mode specified Draw/Read/Both. The mode argument uses OpenGL constants
* so this class provides convenience methods to return them named
* GetDrawMode() GetReadMode() and GetBothMode() so that your code
......@@ -125,7 +120,6 @@
* a DepthBuffer was automatically created for you, you now need to do it
* explicitly using AddDepthAttachment().
*
* This class should be named vtkOpenGLFramebufferObject (FO)
* Note the capitalization of FramebufferObject
*
* @sa
......@@ -135,6 +129,16 @@
#ifndef vtkOpenGLFramebufferObject_h
#define vtkOpenGLFramebufferObject_h
/* Dec 2018 this class has been cleaned up such that
* AddColorAttachment and AddDepthAttachment no longer
* take a mode argument. The mode is determined by how
* the framebuffer is bound. If you are using these methods
* and need to support both the old and new signatures you
* can check for the following define in your code.
*/
#define VTK_UPDATED_FRAMEBUFFER
/**
* A variant of vtkErrorMacro that is used to verify framebuffer
* object completeness. It's provided so that reporting may include
......@@ -299,39 +303,33 @@ public:
//@{
/**
* Directly assign/remove a texture to color attachments.
* Same as the Set methods but also does an attach call
* so the FO has to be bound when called.
*/
void AddColorAttachment(
unsigned int mode,
unsigned int attId,
vtkTextureObject* tex,
unsigned int zslice = 0,
unsigned int format = 0,
unsigned int mipmapLevel = 0);
void AddColorAttachment(
unsigned int mode,
unsigned int attId,
vtkRenderbuffer* tex);
void RemoveColorAttachment(unsigned int mode, unsigned int index);
void RemoveColorAttachments(unsigned int mode, unsigned int num);
void RemoveColorAttachment(unsigned int index);
void RemoveColorAttachments(unsigned int num);
//@}
/**
* Return the number of color attachments for the given mode
*/
int GetNumberOfColorAttachments(unsigned int mode);
int GetNumberOfColorAttachments();
//@{
/**
* Directly assign/remove a texture/renderbuffer to depth attachments.
*/
void AddDepthAttachment() {
this->AddDepthAttachment(this->GetBothMode()); }
void AddDepthAttachment(unsigned int mode);
void AddDepthAttachment(unsigned int mode, vtkTextureObject* tex);
void AddDepthAttachment(unsigned int mode, vtkRenderbuffer* tex);
void RemoveDepthAttachment(unsigned int mode);
void AddDepthAttachment();
void AddDepthAttachment(vtkTextureObject* tex);
void AddDepthAttachment(vtkRenderbuffer* tex);
void RemoveDepthAttachment();
//@}
//@{
......@@ -494,35 +492,12 @@ public:
*/
void Resize(int width, int height);
// Deprecated
void RemoveTexColorAttachments(unsigned int mode, unsigned int num)
{ this->RemoveColorAttachments(mode, num); }
void RemoveTexColorAttachment(unsigned int mode, unsigned int attId)
{ this->RemoveColorAttachment(mode, attId); }
void RemoveRenDepthAttachment(unsigned int mode)
{ this->RemoveDepthAttachment(mode); }
void RemoveTexDepthAttachment(unsigned int mode)
{ this->RemoveDepthAttachment(mode); }
protected:
void SetColorBuffer(unsigned int mode,
unsigned int index, vtkTextureObject *texture,
unsigned int zslice=0, unsigned int format=0, unsigned int mipmapLevel=0);
void SetColorBuffer(unsigned int mode,
unsigned int index, vtkRenderbuffer *rb);
void SetDepthBuffer(unsigned int mode, vtkTextureObject *depthTexture);
void SetDepthBuffer(unsigned int mode, vtkRenderbuffer *depthBuffer);
/**
* Attach all buffers to the FO if not already done so
*/
void Attach();
/**
* Attach a specific buffer
*/
void AttachColorBuffer(unsigned int mode, unsigned int index);
void AttachDepthBuffer(unsigned int mode);
void AttachColorBuffer(unsigned int index);
void AttachDepthBuffer();
/**
* Load all necessary extensions.
......@@ -598,10 +573,8 @@ protected:
int LastSize[2];
std::vector<unsigned int> ActiveBuffers;
vtkFOInfo *DrawDepthBuffer;
vtkFOInfo *ReadDepthBuffer;
std::map<unsigned int, vtkFOInfo *> DrawColorBuffers;
std::map<unsigned int, vtkFOInfo *> ReadColorBuffers;
vtkFOInfo *DepthBuffer;
std::map<unsigned int, vtkFOInfo *> ColorBuffers;
private:
vtkOpenGLFramebufferObject(const vtkOpenGLFramebufferObject&) = delete;
......
......@@ -134,7 +134,7 @@ void vtkOpenGLImageAlgorithmHelper::Execute(
vtkOpenGLState *ostate = this->RenderWindow->GetState();
outputTex->Create2D(outDims[0], outDims[1], 4, VTK_FLOAT, false);
fbo->AddColorAttachment(fbo->GetDrawMode(), 0, outputTex);
fbo->AddColorAttachment(0, outputTex);
// because the same FBO can be used in another pass but with several color
// buffers, force this pass to use 1, to avoid side effects from the
......
......@@ -277,14 +277,9 @@ void vtkOrderIndependentTranslucentPass::Render(const vtkRenderState *s)
this->Framebuffer->SetContext(renWin);
this->Framebuffer->SaveCurrentBindingsAndBuffers();
this->Framebuffer->Bind();
this->Framebuffer->AddDepthAttachment(
this->Framebuffer->GetBothMode(), this->TranslucentZTexture);
this->Framebuffer->AddColorAttachment(
this->Framebuffer->GetBothMode(), 0,
this->TranslucentRGBATexture);
this->Framebuffer->AddColorAttachment(
this->Framebuffer->GetDrawMode(), 1,
this->TranslucentRTexture);
this->Framebuffer->AddDepthAttachment(this->TranslucentZTexture);
this->Framebuffer->AddColorAttachment(0, this->TranslucentRGBATexture);
this->Framebuffer->AddColorAttachment(1, this->TranslucentRTexture);
this->Framebuffer->RestorePreviousBindingsAndBuffers();
}
......
......@@ -151,7 +151,7 @@ void vtkPanoramicProjectionPass::InitOpenGLResources(vtkOpenGLRenderWindow* renW
this->FrameBufferObject->SetContext(renWin);
this->FrameBufferObject->SaveCurrentBindingsAndBuffers();
this->FrameBufferObject->Resize(this->CubeResolution, this->CubeResolution);
this->FrameBufferObject->AddDepthAttachment(vtkOpenGLFramebufferObject::GetDrawMode());
this->FrameBufferObject->AddDepthAttachment();
this->FrameBufferObject->RestorePreviousBindingsAndBuffers();
}
}
......@@ -331,13 +331,9 @@ void vtkPanoramicProjectionPass::RenderOnFace(const vtkRenderState* s, int faceI
s2.SetFrameBuffer(this->FrameBufferObject);
this->CubeMapTexture->Activate();
this->FrameBufferObject->SaveCurrentBindingsAndBuffers();
this->FrameBufferObject->RemoveColorAttachments(vtkOpenGLFramebufferObject::GetBothMode(), 6);
this->FrameBufferObject->AddColorAttachment(
vtkOpenGLFramebufferObject::GetBothMode(), 0, this->CubeMapTexture, 0, faceIndex);
this->FrameBufferObject->Bind();
this->FrameBufferObject->AddColorAttachment(0, this->CubeMapTexture, 0, faceIndex);
this->FrameBufferObject->ActivateBuffer(0);
this->FrameBufferObject->Start(this->CubeResolution, this->CubeResolution);
......@@ -349,8 +345,8 @@ void vtkPanoramicProjectionPass::RenderOnFace(const vtkRenderState* s, int faceI
r->SetUserLightTransform(nullptr);
this->FrameBufferObject->RemoveColorAttachment(0);
this->FrameBufferObject->RestorePreviousBindingsAndBuffers();
this->CubeMapTexture->Deactivate();
r->SetActiveCamera(oldCamera);
}
......
......@@ -150,13 +150,11 @@ void vtkSSAAPass::Render(const vtkRenderState *s)
vtkRenderState s2(r);
s2.SetPropArrayAndCount(s->GetPropArray(),s->GetPropArrayCount());
s2.SetFrameBuffer(this->FrameBufferObject);
this->FrameBufferObject->AddColorAttachment(
this->FrameBufferObject->GetBothMode(), 0,this->Pass1);
this->FrameBufferObject->Bind();
this->FrameBufferObject->AddColorAttachment(0,this->Pass1);
this->FrameBufferObject->ActivateDrawBuffer(0);
this->FrameBufferObject->AddDepthAttachment(
this->FrameBufferObject->GetBothMode());
this->FrameBufferObject->AddDepthAttachment();
this->FrameBufferObject->StartNonOrtho(w,h);
ostate->vtkglViewport(0, 0, w, h);
ostate->vtkglScissor(0, 0, w, h);
......@@ -181,8 +179,7 @@ void vtkSSAAPass::Render(const vtkRenderState *s)
VTK_UNSIGNED_CHAR,false);
}
this->FrameBufferObject->AddColorAttachment(
this->FrameBufferObject->GetBothMode(), 0,this->Pass2);
this->FrameBufferObject->AddColorAttachment(0,this->Pass2);
this->FrameBufferObject->Start(width,h);
// Use a subsample shader, do it horizontally. this->Pass1 is the source
......
......@@ -373,6 +373,7 @@ void vtkShadowMapBakerPass::Render(const vtkRenderState *s)
this->FrameBufferObject->SetContext(context);
this->FrameBufferObject->SaveCurrentBindingsAndBuffers();
this->FrameBufferObject->Resize(this->Resolution, this->Resolution);
this->FrameBufferObject->Bind();
this->FrameBufferObject->AddDepthAttachment();
}
else
......@@ -493,8 +494,7 @@ void vtkShadowMapBakerPass::Render(const vtkRenderState *s)
r->SetActiveCamera(lightCamera);
//map->Activate();
this->FrameBufferObject->AddColorAttachment(
this->FrameBufferObject->GetBothMode(), 0, map);
this->FrameBufferObject->AddColorAttachment(0, map);
this->FrameBufferObject->ActivateBuffer(0);
this->FrameBufferObject->Resize(
static_cast<int>(this->Resolution),
......
......@@ -227,8 +227,7 @@ void vtkSimpleMotionBlurPass::Render(const vtkRenderState *s)
renWin->GetShaderCache()->ReadyShaderProgram(this->BlendProgram->Program);
}
this->FrameBufferObject->AddColorAttachment(
this->FrameBufferObject->GetBothMode(), 0,
this->FrameBufferObject->AddColorAttachment(0,
this->AccumulationTexture[this->ActiveAccumulationTexture]);
ostate->vtkglViewport(0, 0,
......@@ -269,8 +268,7 @@ void vtkSimpleMotionBlurPass::Render(const vtkRenderState *s)
this->CurrentSubFrame++;
if (this->CurrentSubFrame < this->SubFrames)
{
this->FrameBufferObject->AddColorAttachment(
this->FrameBufferObject->GetBothMode(), 0,
this->FrameBufferObject->AddColorAttachment(0,
this->AccumulationTexture[
this->ActiveAccumulationTexture == 0 ? 1 : 0]);
}
......
......@@ -228,10 +228,8 @@ void vtkSobelGradientMagnitudePass::Render(const vtkRenderState *s)
cout << "gx1 TOid=" << this->Gx1->GetHandle() <<endl;
cout << "gy1 TOid=" << this->Gy1->GetHandle() <<endl;
#endif
this->FrameBufferObject->AddColorAttachment(
this->FrameBufferObject->GetDrawMode(), 0,this->Gx1);
this->FrameBufferObject->AddColorAttachment(
this->FrameBufferObject->GetDrawMode(), 1,this->Gy1);
this->FrameBufferObject->AddColorAttachment(0,this->Gx1);
this->FrameBufferObject->AddColorAttachment(1,this->Gy1);
unsigned int indices[2]={0,1};
this->FrameBufferObject->ActivateDrawBuffers(indices,2);
......
......@@ -660,10 +660,8 @@ bool vtkValuePass::InitializeFBO(vtkRenderer* ren)
this->ImplFloat->ValueFBO->Bind(GL_FRAMEBUFFER);
this->ImplFloat->ValueFBO->InitializeViewport(size[0], size[1]);
/* GL_COLOR_ATTACHMENT0 */
this->ImplFloat->ValueFBO->AddColorAttachment(GL_FRAMEBUFFER,
0, this->ImplFloat->ValueRBO);
this->ImplFloat->ValueFBO->AddDepthAttachment(GL_FRAMEBUFFER,
this->ImplFloat->DepthRBO);
this->ImplFloat->ValueFBO->AddColorAttachment(0, this->ImplFloat->ValueRBO);
this->ImplFloat->ValueFBO->AddDepthAttachment(this->ImplFloat->DepthRBO);