From 7c3dfb62fd93484a5f5e7f6fa88127907e9f3fcd Mon Sep 17 00:00:00 2001 From: ouv Date: Wed, 12 May 2010 09:04:02 +0000 Subject: [PATCH] Optimization (to avoid endless attempts of initializing OpenGL extensions) --- src/VTKViewer/VTKViewer_PolyDataMapper.cxx | 21 ++++++++------------- src/VTKViewer/VTKViewer_PolyDataMapper.h | 5 ++++- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/VTKViewer/VTKViewer_PolyDataMapper.cxx b/src/VTKViewer/VTKViewer_PolyDataMapper.cxx index 50ea7c8e3..2a0458d22 100644 --- a/src/VTKViewer/VTKViewer_PolyDataMapper.cxx +++ b/src/VTKViewer/VTKViewer_PolyDataMapper.cxx @@ -126,7 +126,7 @@ VTKViewer_PolyDataMapper::VTKViewer_PolyDataMapper() { Q_INIT_RESOURCE( VTKViewer ); - this->ExtensionsInitialized = 0; + this->ExtensionsInitialized = ES_None; this->PointSpriteTexture = 0; @@ -220,24 +220,18 @@ int VTKViewer_PolyDataMapper::GetMarkerTexture() } //----------------------------------------------------------------------------- -bool VTKViewer_PolyDataMapper::InitExtensions() +int VTKViewer_PolyDataMapper::InitExtensions() { - if( this->ExtensionsInitialized ) - return true; - - InitializeBufferExtensions(); - char* ext = (char*)glGetString( GL_EXTENSIONS ); if( !IsBufferExtensionsInitialized || strstr( ext, "GL_ARB_point_sprite" ) == NULL || strstr( ext, "GL_ARB_vertex_buffer_object" ) == NULL ) { - INFOS("Initializing ARB extensions failed"); - return false; + MESSAGE("Initializing ARB extensions failed"); + return ES_Error; } - this->ExtensionsInitialized = 1; - return true; + return ES_Ok; } //----------------------------------------------------------------------------- @@ -296,7 +290,8 @@ void VTKViewer_PolyDataMapper::RenderPiece( vtkRenderer* ren, vtkActor* act ) bool isUsePointSprites = this->MarkerEnabled && this->MarkerType != VTK::MT_NONE; if( isUsePointSprites ) { - this->InitExtensions(); + if( this->ExtensionsInitialized == ES_None ) + this->ExtensionsInitialized = this->InitExtensions(); this->InitPointSprites(); this->InitTextures(); } @@ -542,7 +537,7 @@ int VTKViewer_PolyDataMapper::Draw( vtkRenderer* ren, vtkActor* act ) delete aColorFunctor; } - if( this->ExtensionsInitialized ) { + if( this->ExtensionsInitialized == ES_Ok ) { GLuint aBufferObjectID = 0; vglGenBuffersARB( 1, &aBufferObjectID ); vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID ); diff --git a/src/VTKViewer/VTKViewer_PolyDataMapper.h b/src/VTKViewer/VTKViewer_PolyDataMapper.h index 38b4838fb..9b936f8f9 100644 --- a/src/VTKViewer/VTKViewer_PolyDataMapper.h +++ b/src/VTKViewer/VTKViewer_PolyDataMapper.h @@ -55,6 +55,9 @@ class vtkImageData; */ class VTKVIEWER_EXPORT VTKViewer_PolyDataMapper : public MAPPER_SUPERCLASS { +public: + enum ExtensionsState { ES_None = 0, ES_Error, ES_Ok }; + public: static VTKViewer_PolyDataMapper* New(); vtkTypeRevisionMacro( VTKViewer_PolyDataMapper, MAPPER_SUPERCLASS ); @@ -88,7 +91,7 @@ protected: ~VTKViewer_PolyDataMapper(); //! Initializing OpenGL extensions. - bool InitExtensions(); + int InitExtensions(); //! Activate Point Sprites. void InitPointSprites(); -- 2.39.2