Commit cb27351f authored by François Bertel's avatar François Bertel Committed by David Partyka
Browse files

BUG:Fixed wrong use of OpenGLExtensionManager in vtkOpenGLHAVSVolumeMapper

Warning: It required a API change for the signature of SupportedByHardware().
parent 07f0348a
......@@ -155,7 +155,7 @@ int TestHAVSVolumeMapper(int argc, char *argv[])
renWin->SetSize(300, 300);
renWin->Render();
int supported = volumeMapper->SupportedByHardware();
int supported = volumeMapper->SupportedByHardware(ren1);
vtkTextActor *textActor = vtkTextActor::New();
textActor->SetInput("Required Extensions\nNot Supported");
......
......@@ -162,7 +162,8 @@ public:
// features include off-screen rendering, 32-bit fp textures, multiple
// render targets, and framebuffer objects.
// Subclasses must override this method to indicate if supported by Hardware.
virtual bool SupportedByHardware() {return false; }
virtual bool SupportedByHardware(vtkRenderer *vtkNotUsed(r))
{return false; }
// Description:
// Set/get whether or not the data structures should be stored on the GPU
......
......@@ -32,6 +32,7 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkUnstructuredGrid.h"
#include "vtkUnstructuredGridPartialPreIntegration.h"
#include "vtkVolumeProperty.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkHAVSVolumeMapper_kbufferVP.h"
#include "vtkHAVSVolumeMapper_k2BeginFP.h"
......@@ -54,6 +55,7 @@ vtkOpenGLHAVSVolumeMapper::vtkOpenGLHAVSVolumeMapper()
this->PsiTableTexture = 0;
this->FramebufferObjectSize = 0;
this->OrderedTriangles = 0;
this->RenderWindow=0;
}
//----------------------------------------------------------------------------
......@@ -117,17 +119,16 @@ void vtkOpenGLHAVSVolumeMapper::Initialize(vtkRenderer *ren,
vtkVolume *vol)
{
// Check for the required extensions only.
if (!this->SupportedByHardware())
if (!this->SupportedByHardware(ren))
{
this->InitializationError = vtkHAVSVolumeMapper::UNSUPPORTED_EXTENSIONS;
return;
}
vtkOpenGLExtensionManager * extensions = vtkOpenGLExtensionManager::New();
// Set render window to current render window
extensions->SetRenderWindow(ren->GetRenderWindow());
vtkOpenGLExtensionManager *extensions=
static_cast<vtkOpenGLRenderWindow *>(ren->GetRenderWindow())
->GetExtensionManager();
// Load required extensions
// supports_GL_1_3=1 as checked by this->SupportedByHardware()
......@@ -187,8 +188,6 @@ void vtkOpenGLHAVSVolumeMapper::Initialize(vtkRenderer *ren,
}
}
extensions->Delete();
if (!supports_vertex_buffer_object)
{
this->SetGPUDataStructures(false);
......@@ -524,10 +523,12 @@ void vtkOpenGLHAVSVolumeMapper::InitializeFramebufferObject()
//----------------------------------------------------------------------------
void vtkOpenGLHAVSVolumeMapper::Render(vtkRenderer *ren,
vtkVolume *vol)
vtkVolume *vol)
{
ren->GetRenderWindow()->MakeCurrent();
this->RenderWindow=ren->GetRenderWindow();
if (!this->Initialized)
{
this->InitializationError =
......@@ -1090,45 +1091,45 @@ void vtkOpenGLHAVSVolumeMapper::DrawBlend(int screenWidth, int screenHeight,
//----------------------------------------------------------------------------
void vtkOpenGLHAVSVolumeMapper::PrintSelf(ostream& os, vtkIndent indent)
{
vtkOpenGLExtensionManager * extensions = vtkOpenGLExtensionManager::New();
// set render window to current render window
extensions->SetRenderWindow(NULL);
if ( this->Initialized )
if(this->RenderWindow!=0)
{
os << indent << "Supports GL_VERSION_1_3 (edge_clamp (1.2) and"
<< " multitexture (1.3) minimal version required by"
<< " GL_ARB_draw_buffers): "
<< extensions->ExtensionSupported( "GL_VERSION_1_3" );
os << indent << "Supports GL_VERSION_2_0 (GL_ARB_draw_buffers is a core"
<< "feature): "
<< extensions->ExtensionSupported( "GL_VERSION_2_0" );
os << indent << "Supports GL_ARB_draw_buffers: "
<< extensions->ExtensionSupported( "GL_ARB_draw_buffers" );
os << indent << "Supports GL_EXT_framebuffer_object: "
<< extensions->ExtensionSupported( "GL_EXT_framebuffer_object" )
<< endl;
os << indent << "Supports GL_ARB_vertex_program: "
<< extensions->ExtensionSupported( "GL_ARB_vertex_program" ) << endl;
os << indent << "Supports GL_ARB_fragment_program: "
<< extensions->ExtensionSupported( "GL_ARB_fragment_program" ) << endl;
os << indent << "Supports GL_ARB_texture_float"
<< extensions->ExtensionSupported( "GL_ARB_texture_float" ) << endl;
os << indent << "Supports GL_ATI_texture_float: "
<< extensions->ExtensionSupported( "GL_ATI_texture_float" ) << endl;
os << indent << "Supports GL_VERSION_1_5 (for optional core feature VBO): "
<< extensions->ExtensionSupported( "GL_VERSION_1_5" ) <<endl;
os << indent << "Supports (optional) GL_ARB_vertex_buffer_object: "
<< extensions->ExtensionSupported( "GL_ARB_vertex_buffer_object" )
<<endl;
vtkOpenGLExtensionManager *extensions=
static_cast<vtkOpenGLRenderWindow *>(this->RenderWindow.GetPointer())
->GetExtensionManager();
if ( this->Initialized )
{
os << indent << "Supports GL_VERSION_1_3 (edge_clamp (1.2) and"
<< " multitexture (1.3) minimal version required by"
<< " GL_ARB_draw_buffers): "
<< extensions->ExtensionSupported( "GL_VERSION_1_3" );
os << indent << "Supports GL_VERSION_2_0 (GL_ARB_draw_buffers is a core"
<< "feature): "
<< extensions->ExtensionSupported( "GL_VERSION_2_0" );
os << indent << "Supports GL_ARB_draw_buffers: "
<< extensions->ExtensionSupported( "GL_ARB_draw_buffers" );
os << indent << "Supports GL_EXT_framebuffer_object: "
<< extensions->ExtensionSupported( "GL_EXT_framebuffer_object" )
<< endl;
os << indent << "Supports GL_ARB_vertex_program: "
<< extensions->ExtensionSupported( "GL_ARB_vertex_program" ) << endl;
os << indent << "Supports GL_ARB_fragment_program: "
<< extensions->ExtensionSupported( "GL_ARB_fragment_program" ) << endl;
os << indent << "Supports GL_ARB_texture_float"
<< extensions->ExtensionSupported( "GL_ARB_texture_float" ) << endl;
os << indent << "Supports GL_ATI_texture_float: "
<< extensions->ExtensionSupported( "GL_ATI_texture_float" ) << endl;
os << indent << "Supports GL_VERSION_1_5 (for optional core feature VBO): "
<< extensions->ExtensionSupported( "GL_VERSION_1_5" ) <<endl;
os << indent << "Supports (optional) GL_ARB_vertex_buffer_object: "
<< extensions->ExtensionSupported( "GL_ARB_vertex_buffer_object" )
<<endl;
}
}
extensions->Delete();
os << indent << "Framebuffer Object Size: "
<< this->FramebufferObjectSize << endl;
......@@ -1139,10 +1140,12 @@ void vtkOpenGLHAVSVolumeMapper::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
// Check the OpenGL extension manager for GPU features necessary for the
// HAVS algorithm.
bool vtkOpenGLHAVSVolumeMapper::SupportedByHardware()
bool vtkOpenGLHAVSVolumeMapper::SupportedByHardware(vtkRenderer *r)
{
vtkOpenGLExtensionManager * extensions = vtkOpenGLExtensionManager::New();
vtkOpenGLExtensionManager *extensions=
static_cast<vtkOpenGLRenderWindow *>(r->GetRenderWindow())
->GetExtensionManager();
// Temporarily filter out the Macs, as this mapper makes the ATI driver crash
// (RogueResearch2 on VTK, ATI Radeon X1600 OpenGL Engine 2.0 ATI-1.4.56) and
// makes the Nvidia driver render some corrupted image (kamino on ParaView3
......@@ -1186,8 +1189,6 @@ bool vtkOpenGLHAVSVolumeMapper::SupportedByHardware()
extensions->ExtensionSupported( "GL_ARB_texture_float" );
int supports_GL_ATI_texture_float =
extensions->ExtensionSupported( "GL_ATI_texture_float" );
extensions->Delete();
return !iAmAMac && supports_GL_1_3 && supports_draw_buffers &&
supports_GL_ARB_fragment_program && supports_GL_ARB_vertex_program &&
......
......@@ -107,7 +107,9 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkHAVSVolumeMapper.h"
#include <vtkWeakPointer.h> // to cache the vtkRenderWindow
class vtkRenderer;
class vtkRenderWindow;
class VTK_VOLUMERENDERING_EXPORT vtkOpenGLHAVSVolumeMapper : public vtkHAVSVolumeMapper
......@@ -137,7 +139,7 @@ public:
// features include off-screen rendering, 32-bit fp textures, multiple
// render targets, and framebuffer objects.
// Subclasses must override this method to indicate if supported by Hardware.
virtual bool SupportedByHardware();
virtual bool SupportedByHardware(vtkRenderer *r);
protected:
vtkOpenGLHAVSVolumeMapper();
......@@ -179,6 +181,8 @@ protected:
// Lookup Tables
unsigned int PsiTableTexture;
unsigned int TransferFunctionTexture;
vtkWeakPointer<vtkRenderWindow> RenderWindow;
//ETX
private:
......
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