]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Optimization (to avoid endless attempts of initializing OpenGL extensions)
authorouv <ouv@opencascade.com>
Wed, 12 May 2010 09:04:02 +0000 (09:04 +0000)
committerouv <ouv@opencascade.com>
Wed, 12 May 2010 09:04:02 +0000 (09:04 +0000)
src/VTKViewer/VTKViewer_PolyDataMapper.cxx
src/VTKViewer/VTKViewer_PolyDataMapper.h

index 50ea7c8e32ee605d54834133a7a233502c844547..2a0458d22fe859b96e7f2fda6e27ea66126973a5 100644 (file)
@@ -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 );
index 38b4838fb822990a80e4e0fc84ac5a14a739708a..9b936f8f9fb2b99e3bf27b857b860c0e33d0d765 100644 (file)
@@ -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();