Commit 39010fa7 authored by Ken Martin's avatar Ken Martin

combine fbo and fbo2 into one class and clean it up

having two VBO classes was confusing. This topic
moves the functionality of FBO2 into FBO while
keeping some of the original FBO functionality and
cleaning it up a bit.

All OpenGL2 code in VTK using FBOs is updated in
this topic to use the merged FBO class. Mainly this
impacts classes that were using the FBO class.

The old FBO methods and code are converted but
commented out in this commit.
parent 5ad3a750
......@@ -27,7 +27,7 @@
#include "vtkStructuredExtent.h"
#include "vtkObjectFactory.h"
#include "vtkLineIntegralConvolution2D.h"
#include "vtkFrameBufferObject2.h"
#include "vtkFrameBufferObject.h"
#include "vtkRenderbuffer.h"
#include "vtkPixelBufferObject.h"
#include "vtkTextureObject.h"
......@@ -124,7 +124,7 @@ int vtkImageDataLIC2D::SetContext(vtkRenderWindow * renWin)
bool featureSupport
= vtkLineIntegralConvolution2D::IsSupported(context)
&& vtkPixelBufferObject::IsSupported(context)
&& vtkFrameBufferObject2::IsSupported(context)
&& vtkFrameBufferObject::IsSupported(context)
&& vtkRenderbuffer::IsSupported(context)
&& vtkTextureObject::IsSupported(context);
......@@ -443,7 +443,7 @@ int vtkImageDataLIC2D::RequestData(
magVectorTex->Create2D(magVectorSize[0], magVectorSize[1], 4, VTK_FLOAT, false);
vtkLineIntegralConvolution2D::SetVectorTexParameters(magVectorTex);
vtkFrameBufferObject2 *drawFbo = vtkFrameBufferObject2::New();
vtkFrameBufferObject *drawFbo = vtkFrameBufferObject::New();
drawFbo->SetContext(this->Context);
drawFbo->SaveCurrentBindings();
drawFbo->Bind(GL_FRAMEBUFFER);
......
......@@ -20,7 +20,7 @@
#include "vtkFloatArray.h"
#include "vtkFrameBufferObject2.h"
#include "vtkFrameBufferObject.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLError.h"
......@@ -110,7 +110,7 @@ class vtkLICPingPongBufferManager
{
public:
vtkLICPingPongBufferManager(
vtkFrameBufferObject2 *fbo,
vtkFrameBufferObject *fbo,
unsigned int *bufSize,
vtkTextureObject *vectorTexture,
vtkTextureObject *maskVectorTexture,
......@@ -257,7 +257,7 @@ public:
// Description:
// Clear all the buffers used for writing.
void ClearBuffers(
vtkFrameBufferObject2 *fbo,
vtkFrameBufferObject *fbo,
const vtkPixelExtent &viewExt,
const deque<vtkPixelExtent> &extents,
int clearEETex = 0)
......@@ -312,7 +312,7 @@ public:
// Description:
// Clear the given buffer
void ClearBuffer(
vtkFrameBufferObject2 *fbo,
vtkFrameBufferObject *fbo,
vtkTextureObject *tex,
const vtkPixelExtent &viewExt,
const deque<vtkPixelExtent> &extents)
......@@ -429,7 +429,7 @@ public:
// Description:
// Setup read/write from/to the active lic/seed buffer texture pair
// for LIC pass.
void AttachLICBuffers(vtkFrameBufferObject2 *vtkNotUsed(fbo))
void AttachLICBuffers(vtkFrameBufferObject *vtkNotUsed(fbo))
{
// activate read textures
vtkTextureObject **readTex = this->Textures[this->ReadIndex];
......@@ -465,7 +465,7 @@ public:
// Description:
// Remove input/output bufers used for computing the LIC.
void DettachLICBuffers(vtkFrameBufferObject2 *vtkNotUsed(fbo))
void DettachLICBuffers(vtkFrameBufferObject *vtkNotUsed(fbo))
{
vtkOpenGLStaticCheckErrorMacro("failed at glDrawBuffers");
glFramebufferTexture2D(
......@@ -494,7 +494,7 @@ public:
// Description:
// Attach read/write buffers for transform pass.
void AttachImageVectorBuffer(vtkFrameBufferObject2 *vtkNotUsed(fbo))
void AttachImageVectorBuffer(vtkFrameBufferObject *vtkNotUsed(fbo))
{
this->VectorTexture->Activate();
......@@ -513,7 +513,7 @@ public:
// Description:
// Attach read/write buffers for transform pass.
void DettachImageVectorBuffer(vtkFrameBufferObject2 *vtkNotUsed(fbo))
void DettachImageVectorBuffer(vtkFrameBufferObject *vtkNotUsed(fbo))
{
this->VectorTexture->Deactivate();
......@@ -531,7 +531,7 @@ public:
// Description:
// Attach read/write buffers for EE pass.
void AttachEEBuffer(vtkFrameBufferObject2 *vtkNotUsed(fbo))
void AttachEEBuffer(vtkFrameBufferObject *vtkNotUsed(fbo))
{
vtkTextureObject **readTex = this->Textures[this->ReadIndex];
readTex[0]->Activate();
......@@ -553,7 +553,7 @@ public:
// Description:
// Attach read/write buffers for EE pass.
void DettachEEBuffer(vtkFrameBufferObject2 *vtkNotUsed(fbo))
void DettachEEBuffer(vtkFrameBufferObject *vtkNotUsed(fbo))
{
vtkTextureObject **readTex = this->Textures[this->ReadIndex];
readTex[0]->Deactivate();
......@@ -573,7 +573,7 @@ public:
// Description:
// Deactivates and removes all read/write buffers that were in
// use during the run, restoring a pristine FBO/texture unit state.
void DettachBuffers(vtkFrameBufferObject2 *vtkNotUsed(fbo))
void DettachBuffers(vtkFrameBufferObject *vtkNotUsed(fbo))
{
glFramebufferTexture2D(
GL_DRAW_FRAMEBUFFER,
......@@ -915,7 +915,7 @@ void FindMinMax(
// find min/max of unmasked fragments across all regions
// download each search each region individually
void StreamingFindMinMax(
vtkFrameBufferObject2 *fbo,
vtkFrameBufferObject *fbo,
vtkTextureObject *tex,
const deque<vtkPixelExtent> &extents,
float &min,
......@@ -983,7 +983,7 @@ vtkLineIntegralConvolution2D::vtkLineIntegralConvolution2D()
this->Comm = NULL;
this->Context = NULL;
this->FBO = vtkFrameBufferObject2::New();
this->FBO = vtkFrameBufferObject::New();
this->ShadersNeedBuild = 1;
this->VTShader = NULL;
......@@ -1097,7 +1097,7 @@ bool vtkLineIntegralConvolution2D::IsSupported(vtkRenderWindow *renWin)
}
return vtkTextureObject::IsSupported(context, true, false, false)
&& vtkFrameBufferObject2::IsSupported(context)
&& vtkFrameBufferObject::IsSupported(context)
&& vtkPixelBufferObject::IsSupported(context);
}
......
......@@ -97,7 +97,7 @@
#include "vtkRenderingLICOpenGL2Module.h" // for export macro
#include <deque> // for deque
class vtkFrameBufferObject2;
class vtkFrameBufferObject;
class vtkOpenGLHelper;
class vtkOpenGLRenderWindow;
class vtkPainterCommunicator;
......@@ -409,7 +409,7 @@ protected:
protected:
vtkWeakPointer<vtkOpenGLRenderWindow> Context;
vtkFrameBufferObject2 *FBO;
vtkFrameBufferObject *FBO;
int ShadersNeedBuild;
vtkOpenGLHelper *FinalBlendProgram;
......
......@@ -511,15 +511,16 @@ int vtkStructuredGridLIC2D::RequestData(
vtkFrameBufferObject *fbo = vtkFrameBufferObject::New();
fbo->SetContext(renWin);
fbo->SetColorBuffer(0,vector2);
fbo->SetNumberOfRenderTargets(1);
fbo->SetActiveBuffer(0);
fbo->Bind();
fbo->AddColorAttachment(fbo->GetBothMode(), 0,vector2);
fbo->ActivateDrawBuffer(0);
fbo->ActivateReadBuffer(0);
// TODO --
// step size is incorrect here
// guard pixels are needed for parallel operations
if ( !fbo->Start( magWidth, magHeight, false ) )
if ( !fbo->Start( magWidth, magHeight ) )
{
fbo->Delete();
vector2->Delete();
......
......@@ -14,7 +14,7 @@
#include "vtkSurfaceLICHelper.h"
#include "vtk_glew.h"
#include "vtkFrameBufferObject2.h"
#include "vtkFrameBufferObject.h"
#include "vtkPixelBufferObject.h"
#include "vtkPainterCommunicator.h"
#include "vtkLineIntegralConvolution2D.h"
......@@ -39,7 +39,7 @@
// find min/max of unmasked fragments across all regions
// download each search each region individually
void vtkSurfaceLICHelper::StreamingFindMinMax(
vtkFrameBufferObject2 *fbo,
vtkFrameBufferObject *fbo,
std::deque<vtkPixelExtent> &blockExts,
float &min,
float &max)
......
......@@ -30,7 +30,7 @@
#include <deque> // for methods
class vtkFrameBufferObject2;
class vtkFrameBufferObject;
class vtkOpenGLRenderWindow;
class vtkPainterCommunicator;
class vtkImageData;
......@@ -213,7 +213,7 @@ public:
void GetPixelBounds(float *rgba, int ni, std::deque<vtkPixelExtent> &blockExts);
static void StreamingFindMinMax(
vtkFrameBufferObject2 *fbo,
vtkFrameBufferObject *fbo,
std::deque<vtkPixelExtent> &blockExts,
float &min, float &max);
......@@ -238,7 +238,7 @@ public:
int Viewsize[2];
vtkSmartPointer<vtkSurfaceLICComposite> Compositor;
vtkSmartPointer<vtkFrameBufferObject2> FBO;
vtkSmartPointer<vtkFrameBufferObject> FBO;
vtkSmartPointer<vtkLineIntegralConvolution2D> LICer;
vtkPainterCommunicator *Communicator;
......
......@@ -14,7 +14,7 @@
#include "vtkSurfaceLICInterface.h"
#include "vtkFloatArray.h"
#include "vtkFrameBufferObject2.h"
#include "vtkFrameBufferObject.h"
#include "vtkImageData.h"
#include "vtkLineIntegralConvolution2D.h"
#include "vtkObjectFactory.h"
......@@ -189,7 +189,7 @@ void vtkSurfaceLICInterface::PrepareForGeometry()
// ------------------------------------------- render geometry, project vectors onto screen, etc
// setup our fbo
vtkFrameBufferObject2 *fbo = this->Internals->FBO;
vtkFrameBufferObject *fbo = this->Internals->FBO;
fbo->SaveCurrentBindings();
fbo->Bind(GL_FRAMEBUFFER);
fbo->AddDepthAttachment(GL_DRAW_FRAMEBUFFER, this->Internals->DepthImage);
......@@ -211,7 +211,7 @@ void vtkSurfaceLICInterface::PrepareForGeometry()
void vtkSurfaceLICInterface::CompletedGeometry()
{
vtkFrameBufferObject2 *fbo = this->Internals->FBO;
vtkFrameBufferObject *fbo = this->Internals->FBO;
fbo->RemoveRenDepthAttachment(GL_DRAW_FRAMEBUFFER);
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 0U);
fbo->RemoveTexColorAttachment(GL_DRAW_FRAMEBUFFER, 1U);
......@@ -500,7 +500,7 @@ void vtkSurfaceLICInterface::CombineColorsAndLIC()
this->Internals->Viewsize[0],
this->Internals->Viewsize[1]);
vtkFrameBufferObject2 *fbo = this->Internals->FBO;
vtkFrameBufferObject *fbo = this->Internals->FBO;
fbo->SaveCurrentBindings();
fbo->Bind(GL_FRAMEBUFFER);
fbo->InitializeViewport(this->Internals->Viewsize[0], this->Internals->Viewsize[1]);
......@@ -672,7 +672,7 @@ void vtkSurfaceLICInterface::CopyToScreen()
glBindFramebuffer(GL_FRAMEBUFFER, this->PrevFbo);
glDrawBuffer(this->PrevDrawBuf);
vtkFrameBufferObject2::InitializeViewport(
vtkFrameBufferObject::InitializeViewport(
this->Internals->Viewsize[0],
this->Internals->Viewsize[1]);
glEnable(GL_DEPTH_TEST);
......@@ -1152,7 +1152,7 @@ void vtkSurfaceLICInterface::InitializeResources()
{
initialized = false;
vtkFrameBufferObject2 * fbo = vtkFrameBufferObject2::New();
vtkFrameBufferObject * fbo = vtkFrameBufferObject::New();
fbo->SetContext(this->Internals->Context);
this->Internals->FBO = fbo;
fbo->Delete();
......
......@@ -153,16 +153,16 @@ void vtkDepthImageProcessingPass::RenderDelegate(const vtkRenderState *s,
s2.SetFrameBuffer(fbo);
fbo->SetNumberOfRenderTargets(1);
fbo->SetColorBuffer(0,colortarget);
fbo->AddColorAttachment(
fbo->GetDrawMode(), 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->SetActiveBuffer(0);
fbo->ActivateDrawBuffer(0);
fbo->SetDepthBuffer(depthtarget);
fbo->StartNonOrtho(newWidth,newHeight,false);
fbo->AddDepthAttachment(fbo->GetDrawMode(), depthtarget);
fbo->StartNonOrtho(newWidth, newHeight);
// 2. Delegate render in FBO
//glEnable(GL_DEPTH_TEST);
......
......@@ -42,8 +42,6 @@ vtkDepthOfFieldPass::vtkDepthOfFieldPass()
this->FrameBufferObject=0;
this->Pass1=0;
this->Pass1Depth=0;
this->Supported=false;
this->SupportProbed=false;
this->BlurProgram = NULL;
this->AutomaticFocalDistance = true;
}
......@@ -92,69 +90,6 @@ void vtkDepthOfFieldPass::Render(const vtkRenderState *s)
return;
}
if(!this->SupportProbed)
{
this->SupportProbed=true;
// Test for Hardware support. If not supported, just render the delegate.
bool supported=vtkFrameBufferObject::IsSupported(renWin);
if(!supported)
{
vtkErrorMacro("FBOs are not supported by the context. Cannot blur the image.");
}
if(supported)
{
// FBO extension is supported. Is the specific FBO format supported?
if(this->FrameBufferObject==0)
{
this->FrameBufferObject=vtkFrameBufferObject::New();
this->FrameBufferObject->SetContext(renWin);
}
if(this->Pass1==0)
{
this->Pass1=vtkTextureObject::New();
this->Pass1->SetContext(renWin);
}
this->Pass1->Create2D(64,64,4,VTK_UNSIGNED_CHAR,false);
this->FrameBufferObject->SetColorBuffer(0,this->Pass1);
this->FrameBufferObject->SetNumberOfRenderTargets(1);
this->FrameBufferObject->SetActiveBuffer(0);
this->FrameBufferObject->SetDepthBufferNeeded(true);
#if GL_ES_VERSION_3_0 != 1
GLint savedCurrentDrawBuffer;
glGetIntegerv(GL_DRAW_BUFFER,&savedCurrentDrawBuffer);
#endif
supported=this->FrameBufferObject->StartNonOrtho(64,64,false);
if(!supported)
{
vtkErrorMacro("The requested FBO format is not supported by the context. Cannot blur the image.");
}
else
{
this->FrameBufferObject->UnBind();
#if GL_ES_VERSION_3_0 != 1
glDrawBuffer(static_cast<GLenum>(savedCurrentDrawBuffer));
#endif
}
}
this->Supported=supported;
}
if(!this->Supported)
{
this->DelegatePass->Render(s);
this->NumberOfRenderedProps+=
this->DelegatePass->GetNumberOfRenderedProps();
return;
}
#if GL_ES_VERSION_3_0 != 1
GLint savedDrawBuffer;
glGetIntegerv(GL_DRAW_BUFFER,&savedDrawBuffer);
#endif
// 1. Create a new render state with an FBO.
int width;
......@@ -205,14 +140,12 @@ void vtkDepthOfFieldPass::Render(const vtkRenderState *s)
this->FrameBufferObject->SetContext(renWin);
}
this->FrameBufferObject->SaveCurrentBindingsAndBuffers();
this->RenderDelegate(s,width,height,w,h,this->FrameBufferObject,
this->Pass1, this->Pass1Depth);
this->FrameBufferObject->UnBind();
#if GL_ES_VERSION_3_0 != 1
glDrawBuffer(static_cast<GLenum>(savedDrawBuffer));
#endif
this->FrameBufferObject->RestorePreviousBindingsAndBuffers();
// has something changed that would require us to recreate the shader?
if (!this->BlurProgram)
......
......@@ -98,9 +98,6 @@ public:
// Structures for the various cell types we render.
vtkOpenGLHelper *BlurProgram;
bool Supported;
bool SupportProbed;
bool AutomaticFocalDistance;
private:
......
......@@ -15,7 +15,7 @@
#include "vtkDualDepthPeelingPass.h"
#include "vtkFrameBufferObject2.h"
#include "vtkFrameBufferObject.h"
#include "vtkInformation.h"
#include "vtkInformationKey.h"
#include "vtkNew.h"
......@@ -454,7 +454,7 @@ void vtkDualDepthPeelingPass::Initialize(const vtkRenderState *s)
// Allocate new textures if needed:
if (!this->Framebuffer)
{
this->Framebuffer = vtkFrameBufferObject2::New();
this->Framebuffer = vtkFrameBufferObject::New();
std::generate(this->Textures,
this->Textures + static_cast<int>(NumberOfTextures),
......@@ -513,7 +513,7 @@ void vtkDualDepthPeelingPass::InitFramebuffer(const vtkRenderState *s)
s->GetRenderer()->GetRenderWindow()));
// Save the current FBO bindings to restore them later.
this->Framebuffer->SaveCurrentBindings();
this->Framebuffer->SaveCurrentBindingsAndBuffers(GL_DRAW_FRAMEBUFFER);
this->Framebuffer->Bind(GL_DRAW_FRAMEBUFFER);
this->Framebuffer->AddColorAttachment(GL_DRAW_FRAMEBUFFER, BackTemp,
......@@ -561,7 +561,7 @@ void vtkDualDepthPeelingPass::Prepare()
this->RenderCount = 0;
// Save the current FBO bindings to restore them later.
this->Framebuffer->SaveCurrentBindings();
this->Framebuffer->SaveCurrentBindingsAndBuffers(GL_DRAW_FRAMEBUFFER);
this->Framebuffer->Bind(GL_DRAW_FRAMEBUFFER);
// The source front buffer must be initialized, since it simply uses additive
......@@ -607,10 +607,11 @@ void vtkDualDepthPeelingPass::CopyOpaqueDepthBuffer()
// glBlendEquation = GL_MAX to be used during peeling.
// Copy from the current (default) framebuffer's depth buffer into a texture:
this->Framebuffer->UnBind(GL_DRAW_FRAMEBUFFER);
this->Framebuffer->RestorePreviousBindingsAndBuffers(GL_DRAW_FRAMEBUFFER);
this->Textures[OpaqueDepth]->CopyFromFrameBuffer(
this->ViewportX, this->ViewportY, 0, 0,
this->ViewportWidth, this->ViewportHeight);
this->Framebuffer->SaveCurrentBindingsAndBuffers(GL_DRAW_FRAMEBUFFER);
this->Framebuffer->Bind(GL_DRAW_FRAMEBUFFER);
// Fill both depth buffers with the opaque fragment depths. InitializeDepth
......@@ -911,6 +912,7 @@ void vtkDualDepthPeelingPass::Finalize()
this->TranslucentPass->GetNumberOfRenderedProps();
this->Framebuffer->UnBind(GL_DRAW_FRAMEBUFFER);
this->Framebuffer->RestorePreviousBindingsAndBuffers(GL_DRAW_FRAMEBUFFER);
this->BlendFinalImage();
// Restore blending parameters:
......
......@@ -50,7 +50,7 @@
#include "vtkRenderingOpenGL2Module.h" // For export macro
#include "vtkDepthPeelingPass.h"
class vtkFrameBufferObject2;
class vtkFrameBufferObject;
class vtkOpenGLBufferObject;
class vtkOpenGLVertexArrayObject;
class vtkShaderProgram;
......@@ -186,7 +186,7 @@ protected:
vtkOpenGLVertexArrayObject *BlendVAO;
vtkOpenGLBufferObject *BlendVBO;
vtkFrameBufferObject2 *Framebuffer;
vtkFrameBufferObject *Framebuffer;
vtkTextureObject *Textures[NumberOfTextures];
TextureName FrontSource; // The current front source buffer
......
......@@ -178,6 +178,7 @@ void vtkEDLShading::EDLInitializeFramebuffers(vtkRenderState &s)
this->ProjectionFBO->SetContext(renWin);
}
s.SetFrameBuffer(this->ProjectionFBO);
this->ProjectionFBO->SaveCurrentBindingsAndBuffers();
this->ProjectionFBO->Bind();
// Color texture
if (this->ProjectionColorTexture == 0)
......@@ -208,10 +209,11 @@ void vtkEDLShading::EDLInitializeFramebuffers(vtkRenderState &s)
// Apply textures
// to make things clear, we write all
this->ProjectionFBO->SetNumberOfRenderTargets(1);
this->ProjectionFBO->SetColorBuffer(0, this->ProjectionColorTexture);
this->ProjectionFBO->SetActiveBuffer(0);
this->ProjectionFBO->SetDepthBuffer(this->ProjectionDepthTexture);
this->ProjectionFBO->AddColorAttachment(
this->ProjectionFBO->GetBothMode(), 0, this->ProjectionColorTexture);
this->ProjectionFBO->ActivateDrawBuffer(0);
this->ProjectionFBO->AddDepthAttachment(
this->ProjectionFBO->GetBothMode(), this->ProjectionDepthTexture);
this->ProjectionDepthTexture->SetWrapS(vtkTextureObject::ClampToEdge);
this->ProjectionDepthTexture->SetWrapT(vtkTextureObject::ClampToEdge);
......@@ -242,11 +244,14 @@ void vtkEDLShading::EDLInitializeFramebuffers(vtkRenderState &s)
{
this->EDLHighShadeTexture->Create2D(this->W, this->H, 4, VTK_FLOAT, false);
}
this->EDLHighFBO->SetNumberOfRenderTargets(1);
this->EDLHighFBO->SetColorBuffer(0, this->EDLHighShadeTexture);
this->EDLHighFBO->SetActiveBuffer(0);
this->EDLHighFBO->SetDepthBufferNeeded(false);
this->EDLHighFBO->SaveCurrentBindingsAndBuffers();
this->EDLHighFBO->Bind();
this->EDLHighFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLHighShadeTexture);
this->EDLHighFBO->ActivateDrawBuffer(0);
this->EDLHighFBO->AddDepthAttachment(GL_DRAW_FRAMEBUFFER);
this->EDLHighFBO->UnBind();
this->EDLHighFBO->RestorePreviousBindingsAndBuffers();
// EDL-RES2 FBO and TEXTURE
//
......@@ -282,10 +287,12 @@ void vtkEDLShading::EDLInitializeFramebuffers(vtkRenderState &s)
this->EDLLowBlurTexture->Create2D(this->W / EDLLowResFactor, this->H / EDLLowResFactor,
4, VTK_FLOAT, false);
}
this->EDLLowFBO->SetNumberOfRenderTargets(1);
this->EDLLowFBO->SetColorBuffer(0, this->EDLLowShadeTexture);
this->EDLLowFBO->SetActiveBuffer(0);
this->EDLLowFBO->SetDepthBufferNeeded(false);
this->EDLLowFBO->SaveCurrentBindingsAndBuffers();
this->EDLLowFBO->Bind();
this->EDLLowFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLLowShadeTexture);
this->EDLLowFBO->ActivateDrawBuffer(0);
this->EDLLowFBO->AddDepthAttachment(GL_DRAW_FRAMEBUFFER);
this->EDLLowShadeTexture->SetWrapS(vtkTextureObject::ClampToEdge);
this->EDLLowShadeTexture->SetWrapT(vtkTextureObject::ClampToEdge);
......@@ -302,6 +309,7 @@ void vtkEDLShading::EDLInitializeFramebuffers(vtkRenderState &s)
this->EDLLowBlurTexture->SendParameters();
this->EDLLowFBO->UnBind();
this->EDLLowFBO->RestorePreviousBindingsAndBuffers();
vtkOpenGLCheckErrorMacro("failed after Initialize");
}
......@@ -378,9 +386,11 @@ bool vtkEDLShading::EDLShadeHigh(
//
s.SetFrameBuffer(this->EDLHighFBO);
this->EDLHighShadeTexture->Activate();
this->EDLHighFBO->SetColorBuffer(0, this->EDLHighShadeTexture);
this->EDLHighFBO->SetActiveBuffer(0);
this->EDLHighFBO->Start(this->W, this->H, false);
this->EDLHighFBO->SaveCurrentBindingsAndBuffers();
this->EDLHighFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLHighShadeTexture);
this->EDLHighFBO->ActivateDrawBuffer(0);
this->EDLHighFBO->Start(this->W, this->H);
// DEPTH TEXTURE PARAMETERS
this->ProjectionDepthTexture->Activate();
......@@ -440,6 +450,7 @@ bool vtkEDLShading::EDLShadeHigh(
this->ProjectionDepthTexture->Deactivate();
this->EDLHighShadeTexture->Deactivate();
this->EDLHighFBO->UnBind();
this->EDLHighFBO->RestorePreviousBindingsAndBuffers();
return true; // succeeded
}
......@@ -467,10 +478,12 @@ bool vtkEDLShading::EDLShadeLow(
this->EDLLowShadeTexture->Activate();
this->EDLLowShadeTexture->SetLinearMagnification(true);
this->EDLLowShadeTexture->SendParameters();
this->EDLLowFBO->SetColorBuffer(0, this->EDLLowShadeTexture);
this->EDLLowFBO->SetActiveBuffer(0);
this->EDLLowFBO->SaveCurrentBindingsAndBuffers();
this->EDLLowFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLLowShadeTexture);
this->EDLLowFBO->ActivateDrawBuffer(0);
this->EDLLowFBO->Start(this->W / this->EDLLowResFactor,
this->H / this->EDLLowResFactor, false);
this->H / this->EDLLowResFactor);
// ACTIVATE SHADER
//
......@@ -498,6 +511,7 @@ bool vtkEDLShading::EDLShadeLow(
this->ProjectionDepthTexture->Deactivate();
this->EDLLowShadeTexture->Deactivate();
this->EDLLowFBO->UnBind();
this->EDLLowFBO->RestorePreviousBindingsAndBuffers();
return true; // succeeded
}
......@@ -523,10 +537,11 @@ bool vtkEDLShading::EDLBlurLow(vtkRenderState &s,
//
s.SetFrameBuffer(this->EDLLowFBO);
this->EDLLowBlurTexture->Activate();
this->EDLLowFBO->SetColorBuffer(0, this->EDLLowBlurTexture);
this->EDLLowFBO->SetActiveBuffer(0);
this->EDLLowFBO->Start(this->W / EDLLowResFactor, this->H / EDLLowResFactor,
false);
this->EDLLowFBO->SaveCurrentBindingsAndBuffers();
this->EDLLowFBO->AddColorAttachment(
GL_DRAW_FRAMEBUFFER, 0, this->EDLLowBlurTexture);
this->EDLLowFBO->ActivateDrawBuffer(0);
this->EDLLowFBO->Start(this->W / EDLLowResFactor, this->H / EDLLowResFactor);
// DEPTH TEXTURE PARAMETERS
vtkShaderProgram *prog = this->BilateralProgram.Program;
......@@ -553,6 +568,7 @@ bool vtkEDLShading::EDLBlurLow(vtkRenderState &s,
this->ProjectionDepthTexture->Deactivate();
this->EDLLowFBO->UnBind();
this->EDLLowFBO->RestorePreviousBindingsAndBuffers();
return EDLIsFiltered;
}
......@@ -652,10 +668,6 @@ void vtkEDLShading::Render(const vtkRenderState *s)
if (this->DelegatePass != 0)
{
#if GL_ES_VERSION_3_0 != 1
GLint savedCurrentDrawBuffer;
glGetIntegerv(GL_DRAW_BUFFER,&savedCurrentDrawBuffer);
#endif
//////////////////////////////////////////////////////
//
......@@ -690,6 +702,7 @@ void vtkEDLShading::Render(const vtkRenderState *s)
this->Zf = zfar;
this->Zn = znear;
//cout << " -- ZNEAR/ZFAR : " << Zn << " || " << Zf << endl;
this->ProjectionFBO->SaveCurrentBindingsAndBuffers();
this->ProjectionFBO->Bind();
this->RenderDelegate(s,this->Width,this->Height,
this->W,this->H,this->ProjectionFBO,
......@@ -706,7 +719,7 @@ void vtkEDLShading::Render(const vtkRenderState *s)
#if EDL_HIGH_RESOLUTION_ON
if(! this->EDLShadeHigh(s2,renWin) )
{
glDrawBuffer(savedCurrentDrawBuffer);
this->ProjectionFBO->RestorePreviousBindingsAndBuffers();
}
#endif // EDL_HIGH_RESOLUTION_ON
......@@ -717,9 +730,7 @@ void vtkEDLShading::Render(const vtkRenderState *s)
#if EDL_LOW_RESOLUTION_ON
if(! this->EDLShadeLow(s2, renWin) )
{
#if GL_ES_VERSION_3_0 != 1
glDrawBuffer(static_cast<GLenum>(savedCurrentDrawBuffer));
#endif
this->ProjectionFBO->RestorePreviousBindingsAndBuffers();
}
if (this->EDLIsFiltered)
{
......@@ -735,9 +746,7 @@ void vtkEDLShading::Render(const vtkRenderState *s)
{
vtkFrameBufferObject::SafeDownCast(s->GetFrameBuffer())->Bind();
}
#if GL_ES_VERSION_3_0 != 1
glDrawBuffer(static_cast<GLenum>(savedCurrentDrawBuffer));
#endif
this->ProjectionFBO->RestorePreviousBindingsAndBuffers();
if( ! this->EDLCompose(s, renWin))
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -51,8 +51,6 @@ vtkGaussianBlurPass::vtkGaussianBlurPass()
this->FrameBufferObject=0;
this->Pass1=0;
this->Pass2=0;
this->Supported=false;
this->SupportProbed=false;
this->BlurProgram = NULL;
}
......@@ -96,78 +94,6 @@ void vtkGaussianBlurPass::Render(const vtkRenderState *s)
if(this->DelegatePass!=0)
{
if(!this->SupportProbed)
{
this->SupportProbed=true;
// Test for Hardware support. If not supported, just render the delegate.
bool supported=vtkFrameBufferObject::IsSupported(renWin);
if(!supported)
{
vtkErrorMacro("FBOs are not supported by the context. Cannot blur the image.");
}
if(supported)
{
supported=vtkTextureObject::IsSupported(renWin);
if(!supported)
{
vtkErrorMacro("Texture Objects are not supported by the context. Cannot blur the image.");
}
}
if(supported)
{
// FBO extension is supported. Is the specific FBO format supported?
if(this->FrameBufferObject==0)
{
this->FrameBufferObject=vtkFrameBufferObject::New();