]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
working with vertex program corrected
authorouv <ouv@opencascade.com>
Wed, 5 Oct 2005 11:53:45 +0000 (11:53 +0000)
committerouv <ouv@opencascade.com>
Wed, 5 Oct 2005 11:53:45 +0000 (11:53 +0000)
src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx
src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx

index 5e67af59d3e26155f21c9de3422c3de6760c3f33..9f651445907ae2baaaf7b84084fcf854f8e52a21 100755 (executable)
@@ -98,7 +98,7 @@ PFNGLVERTEXATTRIB1FARBPROC           glVertexAttrib1fARB          = NULL;
 */
 
 #ifdef GL_ARB_shader_objects
-GLhandleARB VISU_OpenGLPointSpriteMapper::VertexProgram = 0;
+//GLhandleARB VISU_OpenGLPointSpriteMapper::VertexProgram = 0;
 #endif
 
 
@@ -306,16 +306,22 @@ void VISU_OpenGLPointSpriteMapper::SetShaderVariable( const char* variable, floa
   //cout << glGetAttribLocationARB( VISU_OpenGLPointSpriteMapper::VertexProgram, variable ) << " ";
   //cout << variable << " " << value << endl;
 
-  glVertexAttrib1fARB( glGetAttribLocationARB( VISU_OpenGLPointSpriteMapper::VertexProgram, variable ), value );
+  //glVertexAttrib1fARB( glGetAttribLocationARB( VISU_OpenGLPointSpriteMapper::VertexProgram, variable ), value );
+  glVertexAttrib1fARB( glGetAttribLocationARB( myVertexProgram, variable ), value );
 }
 #endif
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::SetPointSpriteResults( bool theResults )
 {
+  float aResults = theResults ? 1.0 : 0.0;
+
+  //cout << "SetPointSpriteResults " << this << " " << aResults << endl;
+
   this->PointSpriteResults = theResults;
 #ifdef GL_ARB_shader_objects
-  this->SetShaderVariable( "results", theResults );
+  this->SetShaderVariable( "results", aResults );
 #endif
+  this->Modified();
 }
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp( float theClamp )
@@ -324,6 +330,7 @@ void VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp( float theClamp )
 #ifdef GL_ARB_shader_objects
   this->SetShaderVariable( "clamp", theClamp );
 #endif
+  this->Modified();
 }
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::SetPointSpriteSize( float theSize )
@@ -332,6 +339,7 @@ void VISU_OpenGLPointSpriteMapper::SetPointSpriteSize( float theSize )
 #ifdef GL_ARB_shader_objects
   this->SetShaderVariable( "geomSize", theSize );
 #endif
+  this->Modified();
 }
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize( float theMinSize )
@@ -340,6 +348,7 @@ void VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize( float theMinSize )
 #ifdef GL_ARB_shader_objects
   this->SetShaderVariable( "minSize", theMinSize );
 #endif
+  this->Modified();
 }
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::SetPointSpriteMaxSize( float theMaxSize )
@@ -348,6 +357,7 @@ void VISU_OpenGLPointSpriteMapper::SetPointSpriteMaxSize( float theMaxSize )
 #ifdef GL_ARB_shader_objects
   this->SetShaderVariable( "maxSize", theMaxSize );
 #endif
+  this->Modified();
 }
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification( float theMagnification )
@@ -356,6 +366,13 @@ void VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification( float theMagnifi
 #ifdef GL_ARB_shader_objects
   this->SetShaderVariable( "magnification", theMagnification );
 #endif
+  this->Modified();
+}
+//-----------------------------------------------------------------------------
+void VISU_OpenGLPointSpriteMapper::SetPointSpriteAlphaThreshold( float theAlphaThreshold )
+{
+  this->PointSpriteAlphaThreshold = theAlphaThreshold;
+  this->Modified();
 }
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::InitExtensions()
@@ -405,12 +422,13 @@ void VISU_OpenGLPointSpriteMapper::InitExtensions()
     //if( !VISU_OpenGLPointSpriteMapper::VertexProgram )
     {
       this->OpenGLLibrary = dlopen( "libGL.so", RTLD_LAZY );
-      VISU_OpenGLPointSpriteMapper::VertexProgram = this->InitShader();
+      //VISU_OpenGLPointSpriteMapper::VertexProgram = this->InitShader();
+      myVertexProgram = this->InitShader();
     }
 
-    PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB =
-      (PFNGLUSEPROGRAMOBJECTARBPROC)dlsym( this->OpenGLLibrary, "glUseProgramObjectARB" );
-    glUseProgramObjectARB( VISU_OpenGLPointSpriteMapper::VertexProgram );
+    //PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB =
+    //  (PFNGLUSEPROGRAMOBJECTARBPROC)dlsym( this->OpenGLLibrary, "glUseProgramObjectARB" );
+    //glUseProgramObjectARB( VISU_OpenGLPointSpriteMapper::VertexProgram );
 
     this->SetShaderVariable( "attrib1",       1.0 );
     this->SetShaderVariable( "attrib2",       1.0 );
@@ -584,6 +602,7 @@ void VISU_OpenGLPointSpriteMapper::InitPointSprites( vtkRenderer* theRenderer, v
       glEnable( GL_BLEND );
       glBlendFunc( GL_SRC_ALPHA, GL_ONE );
 
+      //cout << this << " THRESHOLD " << this->PointSpriteAlphaThreshold << endl;
       glEnable( GL_ALPHA_TEST );
       glAlphaFunc( GL_GREATER, this->PointSpriteAlphaThreshold );
       break;
@@ -654,6 +673,8 @@ void VISU_OpenGLPointSpriteMapper::InitPointSprites( vtkRenderer* theRenderer, v
 void VISU_OpenGLPointSpriteMapper::CleanupPointSprites()
 {
   // Set GL params back to normal to stop other vtkMappers diusplaying wrongly
+  glDisable( GL_ALPHA_TEST );
+
   glEnable( GL_BLEND );
 
   glEnable( GL_DEPTH_TEST );
@@ -731,10 +752,14 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx,
   glPointSize( this->DefaultPointSize );
 
 #ifdef GL_ARB_vertex_buffer_object
+  PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB =
+    (PFNGLUSEPROGRAMOBJECTARBPROC)dlsym( this->OpenGLLibrary, "glUseProgramObjectARB" );
   PFNGLGENBUFFERSARBPROC glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)dlsym( this->OpenGLLibrary, "glGenBuffersARB" );
   PFNGLBINDBUFFERARBPROC glBindBufferARB = (PFNGLBINDBUFFERARBPROC)dlsym( this->OpenGLLibrary, "glBindBufferARB" );
   PFNGLBUFFERDATAARBPROC glBufferDataARB = (PFNGLBUFFERDATAARBPROC)dlsym( this->OpenGLLibrary, "glBufferDataARB" );
 
+  glUseProgramObjectARB( myVertexProgram );
+
   TVertex* aVertex = new TVertex[ this->TotalCells ];
 
   vtkIdType *pts = 0;
@@ -788,6 +813,8 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx,
   glDisableClientState(GL_VERTEX_ARRAY);
 #endif
 
+  glUseProgramObjectARB( 0 );
+
   if( this->UsePointSprites )
     this->CleanupPointSprites();
 }
index 848070cd5b7dc51145c44d472e42d82fc8cc940c..5d624624c1087a2781a14a81bb64ce3e2a961373 100755 (executable)
@@ -155,6 +155,7 @@ public:
   // Point Sprite drawing mode
   // (Results - multicolor, Geometry - fixed color)
   vtkGetMacro(PointSpriteResults, bool);
+  void SetPointSpriteResults( bool );
 
   // Description:
   // Point Sprite size parameters
@@ -164,7 +165,6 @@ public:
   vtkGetMacro(PointSpriteMaxSize, float);
   vtkGetMacro(PointSpriteMagnification, float);
 
-  void SetPointSpriteResults( bool );
   void SetPointSpriteClamp( float );
   void SetPointSpriteSize( float );
   void SetPointSpriteMinSize( float );
@@ -172,7 +172,7 @@ public:
   void SetPointSpriteMagnification( float );
 
   vtkGetMacro(PointSpriteAlphaThreshold, float);
-  vtkSetMacro(PointSpriteAlphaThreshold, float);
+  void SetPointSpriteAlphaThreshold( float );
 
   void SetImageData(vtkImageData* theImageData);
   vtkImageData* GetImageData();
@@ -225,6 +225,7 @@ protected:
 
   static GLhandleARB VertexProgram;
   void*             OpenGLLibrary;
+  GLhandleARB       myVertexProgram;
 #endif
 
   bool              PointSpriteResults;