Commit 0417f5bb authored by Francois Bertel's avatar Francois Bertel

BUG:Probe HW support for FBO, GLSL and texture objects. If not supported, just render the delegate.

parent 5779f5b5
......@@ -38,7 +38,7 @@
#include "vtkPixelBufferObject.h"
#include "vtkImageExtractComponents.h"
vtkCxxRevisionMacro(vtkGaussianBlurPass, "1.2");
vtkCxxRevisionMacro(vtkGaussianBlurPass, "1.3");
vtkStandardNewMacro(vtkGaussianBlurPass);
vtkCxxSetObjectMacro(vtkGaussianBlurPass,DelegatePass,vtkRenderPass);
......@@ -107,13 +107,49 @@ void vtkGaussianBlurPass::Render(const vtkRenderState *s)
this->NumberOfRenderedProps=0;
vtkRenderer *r=s->GetRenderer();
if(this->DelegatePass!=0)
{
// Test for Hardware support. If not supported, just render the delegate.
bool supported=vtkFrameBufferObject::IsSupported(r->GetRenderWindow());
if(!supported)
{
vtkErrorMacro("FBOs are not supported by the context. Cannot blur the image.");
}
if(supported)
{
supported=vtkTextureObject::IsSupported(r->GetRenderWindow());
if(!supported)
{
vtkErrorMacro("Texture Objects are not supported by the context. Cannot blur the image.");
}
}
if(supported)
{
supported=
vtkShaderProgram2::IsSupported(static_cast<vtkOpenGLRenderWindow *>(
r->GetRenderWindow()));
if(!supported)
{
vtkErrorMacro("GLSL is not supported by the context. Cannot blur the image.");
}
}
if(!supported)
{
this->DelegatePass->Render(s);
this->NumberOfRenderedProps+=
this->DelegatePass->GetNumberOfRenderedProps();
return;
}
GLint savedDrawBuffer;
glGetIntegerv(GL_DRAW_BUFFER,&savedDrawBuffer);
// 1. Create a new render state with an FBO.
vtkRenderer *r=s->GetRenderer();
int width=0;
int height=0;
......
......@@ -27,6 +27,10 @@
//
// Its delegate is usually set to a vtkCameraPass or to a post-processing pass.
//
// This pass requires a OpenGL context that supports texture objects (TO),
// framebuffer objects (FBO) and GLSL. If not, it will emit an error message
// and will render its delegate and return.
//
// .SECTION Implementation
// As the filter is separable, it first blurs the image horizontally and then
// vertically. This reduces the number of texture sampling to 5 per pass.
......
......@@ -38,7 +38,7 @@
#include "vtkPixelBufferObject.h"
#include "vtkImageExtractComponents.h"
vtkCxxRevisionMacro(vtkSobelGradientMagnitudePass, "1.2");
vtkCxxRevisionMacro(vtkSobelGradientMagnitudePass, "1.3");
vtkStandardNewMacro(vtkSobelGradientMagnitudePass);
vtkCxxSetObjectMacro(vtkSobelGradientMagnitudePass,DelegatePass,vtkRenderPass);
......@@ -120,11 +120,47 @@ void vtkSobelGradientMagnitudePass::Render(const vtkRenderState *s)
if(this->DelegatePass!=0)
{
vtkRenderer *r=s->GetRenderer();
// Test for Hardware support. If not supported, just render the delegate.
bool supported=vtkFrameBufferObject::IsSupported(r->GetRenderWindow());
if(!supported)
{
vtkErrorMacro("FBOs are not supported by the context. Cannot detect edges on the image.");
}
if(supported)
{
supported=vtkTextureObject::IsSupported(r->GetRenderWindow());
if(!supported)
{
vtkErrorMacro("Texture Objects are not supported by the context. Cannot detect edges on the image.");
}
}
if(supported)
{
supported=
vtkShaderProgram2::IsSupported(static_cast<vtkOpenGLRenderWindow *>(
r->GetRenderWindow()));
if(!supported)
{
vtkErrorMacro("GLSL is not supported by the context. Cannot detect edges on the image.");
}
}
if(!supported)
{
this->DelegatePass->Render(s);
this->NumberOfRenderedProps+=
this->DelegatePass->GetNumberOfRenderedProps();
return;
}
GLint savedDrawBuffer;
glGetIntegerv(GL_DRAW_BUFFER,&savedDrawBuffer);
// 1. Create a new render state with an FBO.
vtkRenderer *r=s->GetRenderer();
int width=0;
int height=0;
......
......@@ -27,6 +27,10 @@
//
// Its delegate is usually set to a vtkCameraPass or to a post-processing pass.
//
// This pass requires a OpenGL context that supports texture objects (TO),
// framebuffer objects (FBO) and GLSL. If not, it will emit an error message
// and will render its delegate and return.
//
// .SECTION Implementation
// To compute the gradient magnitude, the x and y components of the gradient
// (Gx and Gy) have to be computed first. Each computation of Gx and Gy uses
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment