]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Code cleaning
authorouv <ouv@opencascade.com>
Mon, 19 Sep 2005 09:03:11 +0000 (09:03 +0000)
committerouv <ouv@opencascade.com>
Mon, 19 Sep 2005 09:03:11 +0000 (09:03 +0000)
src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx
src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx

index 421de65f42146303ed42b2b738467de01cfc31f5..327ff5f9af64a850734bde41ba40003167ba4552 100755 (executable)
 #include "vtkTriangle.h"
 #include "vtkOpenGLRenderWindow.h"
 #include "vtkOpenGLTexture.h"
-#include "vtkBMPReader.h"
 #include "vtkXMLImageDataReader.h"
 #include "vtkImageData.h"
 
 #include <GL/glext.h>
-#include <GL/glx.h>
+//#include <GL/glx.h>
 
 #include <dlfcn.h>
 
@@ -101,44 +100,39 @@ PFNGLVERTEXATTRIB1FARBPROC           glVertexAttrib1fARB          = NULL;
 #endif
 */
 
-//-----------------------------------------------------------------------------
-vtkCxxSetObjectMacro(VISU_OpenGLPointSpriteMapper, ParticleImage, vtkImageData);
+#ifdef GL_ARB_shader_objects
+GLhandleARB VISU_OpenGLPointSpriteMapper::VertexProgram = 0;
+#endif
+
 //-----------------------------------------------------------------------------
 // Construct empty object.
 VISU_OpenGLPointSpriteMapper::VISU_OpenGLPointSpriteMapper()
 {
-  this->ListId                = 0;
-  this->TotalCells            = 0;
-  this->ExtensionsInitialized = 0;
-  this->ExtensionsOK          = 0;
-  this->ParticleImage         = NULL;
-  this->ParticleImageFileName = NULL;
-  this->AlphaChannelArray     = NULL;
-  this->SizeChannelArray      = NULL;
-  this->ParticleTexture       = NULL;
-  this->bmpReader             = NULL;
-  this->gaussian              = vtkImageData::New();
-  if (!this->bmpReader)
-  {
-    this->bmpReader = vtkBMPReader::New();
-  }
-  this->DefaultPointSize      = 30.0; //-1.0;
-  this->MaximumSupportedSize  =  0.0;
+  this->ListId                   = 0;
+  this->TotalCells               = 0;
+  this->ExtensionsInitialized    = 0;
+  this->ExtensionsOK             = 0;
+  this->AlphaChannelArray        = NULL;
+  this->SizeChannelArray         = NULL;
+  this->DefaultPointSize         = 30.0;
   this->QuadraticPointDistanceAttenuation[0] = 1.0;
   this->QuadraticPointDistanceAttenuation[1] = 0.0;
   this->QuadraticPointDistanceAttenuation[2] = 0.0;
 
-  this->RenderMode            = VISU_OpenGLPointSpriteMapper::Accumulate;
+  this->RenderMode               = VISU_OpenGLPointSpriteMapper::Accumulate;
 
 #ifdef GL_ARB_shader_objects
-  this->OpenGLLibrary         = 0;
-  this->VertexShader          = 0;
-  this->VertexProgram         = 0;
+  this->OpenGLLibrary            = 0;
 #endif
 
-  this->XMLImageDataReader    = vtkXMLImageDataReader::New();
-  this->PointSpriteTexture    = 0;
-  this->IsUsingOpenGLMapper   = false;
+  this->PointSpriteClamp         = 100.0;
+  this->PointSpriteMinSize       =  15.0;
+  this->PointSpriteMaxSize       =  50.0;
+  this->PointSpriteMagnification =   1.0;
+
+  this->XMLImageDataReader       = vtkXMLImageDataReader::New();
+  this->PointSpriteTexture       = 0;
+  this->IsUsingOpenGLMapper      = false;
 }
 //-----------------------------------------------------------------------------
 VISU_OpenGLPointSpriteMapper::~VISU_OpenGLPointSpriteMapper()
@@ -149,11 +143,6 @@ VISU_OpenGLPointSpriteMapper::~VISU_OpenGLPointSpriteMapper()
     {
     this->ReleaseGraphicsResources(this->LastWindow);
     }
-  if (this->ParticleImageFileName)
-    {
-    delete [] this->ParticleImageFileName;
-    this->ParticleImageFileName = NULL;
-    }
   if (this->AlphaChannelArray)
     {
     delete [] this->AlphaChannelArray;
@@ -164,26 +153,6 @@ VISU_OpenGLPointSpriteMapper::~VISU_OpenGLPointSpriteMapper()
     delete [] this->SizeChannelArray;
     this->SizeChannelArray = NULL;
     }
-  if (this->bmpReader)
-  {
-    this->bmpReader->Delete();
-    this->bmpReader = NULL;
-  }
-  if (this->ParticleImage)
-    {
-    this->ParticleImage->Delete();
-    this->ParticleImage = 0;
-    }
-  if (this->ParticleTexture)
-    { // Resources released previously.
-    this->ParticleTexture->Delete();
-    this->ParticleTexture = 0;
-    }
-  if (this->gaussian)
-    {
-    this->gaussian->Delete();
-    this->gaussian = 0;
-    }
   if (this->XMLImageDataReader)
   {
     this->XMLImageDataReader->Delete();
@@ -217,7 +186,7 @@ char* readFromFile( std::string fileName )
 }
 //-----------------------------------------------------------------------------
 #ifdef GL_ARB_shader_objects
-void VISU_OpenGLPointSpriteMapper::printInfoLog( GLhandleARB obj )
+void VISU_OpenGLPointSpriteMapper::PrintInfoLog( GLhandleARB obj )
 {
   PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)dlsym( this->OpenGLLibrary, "glGetObjectParameterivARB" );
   PFNGLGETINFOLOGARBPROC glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)dlsym( this->OpenGLLibrary, "glGetInfoLogARB" );
@@ -238,9 +207,9 @@ void VISU_OpenGLPointSpriteMapper::printInfoLog( GLhandleARB obj )
 }
 #endif
 //-----------------------------------------------------------------------------
-void VISU_OpenGLPointSpriteMapper::InitShader()
-{
 #ifdef GL_ARB_shader_objects
+GLhandleARB VISU_OpenGLPointSpriteMapper::InitShader()
+{
   //cout << "Initializing vertex program" << endl;
 
   std::string fileName = std::string( getenv( "VISU_ROOT_DIR") ) +
@@ -255,24 +224,25 @@ void VISU_OpenGLPointSpriteMapper::InitShader()
   PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)dlsym( this->OpenGLLibrary, "glCreateProgramObjectARB" );
   PFNGLATTACHOBJECTARBPROC glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)dlsym( this->OpenGLLibrary, "glAttachObjectARB" );
   PFNGLLINKPROGRAMPROC glLinkProgramARB = (PFNGLLINKPROGRAMPROC)dlsym( this->OpenGLLibrary, "glLinkProgramARB" );
-  PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)dlsym( this->OpenGLLibrary, "glUseProgramObjectARB" );
+  //PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)dlsym( this->OpenGLLibrary, "glUseProgramObjectARB" );
 
-  this->VertexShader = glCreateShaderObjectARB( GL_VERTEX_SHADER_ARB );
-  glShaderSourceARB( this->VertexShader, 1, (const GLcharARB**)&shader, NULL );
-  glCompileShaderARB( this->VertexShader );
-  //printInfoLog( this->VertexShader );
+  GLhandleARB VertexShader = glCreateShaderObjectARB( GL_VERTEX_SHADER_ARB );
+  glShaderSourceARB( VertexShader, 1, (const GLcharARB**)&shader, NULL );
+  glCompileShaderARB( VertexShader );
+  //this->PrintInfoLog( VertexShader );
 
-  this->VertexProgram = glCreateProgramObjectARB();
-  glAttachObjectARB( this->VertexProgram, this->VertexShader );
+  GLhandleARB VertexProgram = glCreateProgramObjectARB();
+  glAttachObjectARB( VertexProgram, VertexShader );
 
-  glLinkProgramARB( this->VertexProgram );
-  //printInfoLog( this->VertexProgram );
+  glLinkProgramARB( VertexProgram );
+  //this->PrintInfoLog( VertexProgram );
 
-  glUseProgramObjectARB( this->VertexProgram );
+  //glUseProgramObjectARB( this->VertexProgram );
 
-  this->SetShaderVariable( "minSize",  15.0 );
-  this->SetShaderVariable( "maxSize",  50.0 );
-  this->SetShaderVariable( "clamp",   100.0 );
+  //this->SetShaderVariable( "clamp",         100.0 );
+  //this->SetShaderVariable( "minSize",        15.0 );
+  //this->SetShaderVariable( "maxSize",        50.0 );
+  //this->SetShaderVariable( "magnification",   1.0 );
   /*
   cout << "Shader from " << fileName << endl;
   for( int i = 0; i < strlen( shader ); i++ )
@@ -285,22 +255,60 @@ void VISU_OpenGLPointSpriteMapper::InitShader()
     cout << "Loading vertex program... failed" << endl << endl;
   */
   delete shader;
-#endif
 
   glMatrixMode( GL_MODELVIEW );
   glLoadIdentity();
   glTranslatef( 0.0f, 0.0f, -4.0f );
   glRotatef( 0.0f, 1.0f, 0.0f, 0.0f );
   glRotatef( 0.0f, 0.0f, 1.0f, 0.0f );
+
+  return VertexProgram;
 }
+#endif
 //-----------------------------------------------------------------------------
+#ifdef GL_ARB_shader_objects
 void VISU_OpenGLPointSpriteMapper::SetShaderVariable( const char* variable, float value )
 {
-#ifdef GL_ARB_shader_objects
   PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)dlsym( this->OpenGLLibrary, "glGetAttribLocationARB" );
   PFNGLVERTEXATTRIB1FARBPROC glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)dlsym( this->OpenGLLibrary, "glVertexAttrib1fARB" );
 
-  glVertexAttrib1fARB( glGetAttribLocationARB( this->VertexProgram, variable ), value );
+  //cout << VISU_OpenGLPointSpriteMapper::VertexProgram << " ";
+  //cout << glGetAttribLocationARB( VISU_OpenGLPointSpriteMapper::VertexProgram, variable ) << " ";
+  //cout << variable << " " << value << endl;
+
+  glVertexAttrib1fARB( glGetAttribLocationARB( VISU_OpenGLPointSpriteMapper::VertexProgram, variable ), value );
+}
+#endif
+//-----------------------------------------------------------------------------
+void VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp( float theClamp )
+{
+  this->PointSpriteClamp = theClamp;
+#ifdef GL_ARB_shader_objects
+  this->SetShaderVariable( "clamp", theClamp );
+#endif
+}
+//-----------------------------------------------------------------------------
+void VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize( float theMinSize )
+{
+  this->PointSpriteMinSize = theMinSize;
+#ifdef GL_ARB_shader_objects
+  this->SetShaderVariable( "minSize", theMinSize );
+#endif
+}
+//-----------------------------------------------------------------------------
+void VISU_OpenGLPointSpriteMapper::SetPointSpriteMaxSize( float theMaxSize )
+{
+  this->PointSpriteMaxSize = theMaxSize;
+#ifdef GL_ARB_shader_objects
+  this->SetShaderVariable( "maxSize", theMaxSize );
+#endif
+}
+//-----------------------------------------------------------------------------
+void VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification( float theMagnification )
+{
+  this->PointSpriteMagnification = theMagnification;
+#ifdef GL_ARB_shader_objects
+  this->SetShaderVariable( "magnification", theMagnification );
 #endif
 }
 //-----------------------------------------------------------------------------
@@ -345,9 +353,22 @@ void VISU_OpenGLPointSpriteMapper::InitExtensions()
   */
 
 #ifdef GL_ARB_shader_objects
-  this->OpenGLLibrary = dlopen( "libGL.so", RTLD_LAZY );
+  //if( !VISU_OpenGLPointSpriteMapper::VertexProgram )
+  {
+    this->OpenGLLibrary = dlopen( "libGL.so", RTLD_LAZY );
+    VISU_OpenGLPointSpriteMapper::VertexProgram = this->InitShader();
+  }
 
-  this->InitShader();
+  PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)dlsym( this->OpenGLLibrary, "glUseProgramObjectARB" );
+  glUseProgramObjectARB( VISU_OpenGLPointSpriteMapper::VertexProgram );
+
+  this->SetShaderVariable( "attrib1",       1.0 );
+  this->SetShaderVariable( "attrib2",       1.0 );
+  this->SetShaderVariable( "attrib3",       1.0 );
+  this->SetShaderVariable( "clamp",         this->PointSpriteClamp );
+  this->SetShaderVariable( "minSize",       this->PointSpriteMinSize );
+  this->SetShaderVariable( "maxSize",       this->PointSpriteMaxSize );
+  this->SetShaderVariable( "magnification", this->PointSpriteMagnification );
 #endif
 
   this->ExtensionsOK = 1;
@@ -362,7 +383,7 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act)
   if( !this->ExtensionsInitialized && !this->IsUsingOpenGLMapper )
   {
     this->InitExtensions();
-    act->GetProperty()->SetPointSize( 10.0f );
+    //act->GetProperty()->SetPointSize( 10.0f );
   }
 
   if( this->IsUsingOpenGLMapper )
@@ -416,104 +437,7 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act)
 
   // make sure our window is current
   ren->GetRenderWindow()->MakeCurrent();
-  /*
-  // Make sure open GL extensions are initialized
-  if (!this->ExtensionsInitialized)
-  {
-    this->InitExtensions();
-  }
-  if (!this->ExtensionsOK)
-  {
-    return;
-  }
-
-  vtkImageData *particlesource = NULL;
-  if (this->ParticleImageFileName && !this->ParticleImage)
-  {
-    // ensure Particle texture pipeline is up to date.
-    this->bmpReader->SetFileName(this->ParticleImageFileName);
-    particlesource = this->bmpReader->GetOutput();
-  }
-  else
-  {
-    particlesource = this->ParticleImage;
-  }
-
-  particlesource->Update();
-
-  if (particlesource->GetMTime()>this->ParticleBuildTime || this->GetMTime()>this->ParticleBuildTime)
-  {
-    gaussian->CopyStructure(particlesource);
-    //
-    int t = particlesource->GetPointData()->GetScalars()->GetDataType();
-    int c = particlesource->GetPointData()->GetScalars()->GetNumberOfComponents();
-    int N = particlesource->GetPointData()->GetScalars()->GetNumberOfTuples();
-    //
-    vtkUnsignedCharArray *rgba = vtkUnsignedCharArray::New();
-    rgba->SetNumberOfComponents(4);
-    rgba->SetNumberOfTuples(N);
-    gaussian->GetPointData()->SetScalars( rgba );
-    rgba->Delete();
-    unsigned char *newdata = (unsigned char *)(rgba->WritePointer(0,N));
-    //
-    switch (t)
-    {
-      case VTK_UNSIGNED_CHAR:
-      case VTK_SHORT:
-      {
-        unsigned char *bmpdata = (unsigned char *)(particlesource->GetPointData()->GetScalars()->GetVoidPointer(0));
-        for (int i=0; i<N; i++)
-        {
-          newdata[i*4 + 0] = bmpdata[i*3 + 0];
-          newdata[i*4 + 1] = bmpdata[i*3 + 1];
-          newdata[i*4 + 2] = bmpdata[i*3 + 2];
-          double temp = bmpdata[i*3 + 0] + bmpdata[i*3 + 1] + bmpdata[i*3 + 2];
-          if (temp>255) temp = 255;
-          newdata[i*4 + 3] = static_cast<unsigned char>(std::floor(std::sqrt(temp*temp)+0.5));
-          int val = newdata[i*4 + 3];
-        }
-        break;
-      }
-      //
-      case VTK_DOUBLE:
-      case 10:
-      {
-        double *bmpdata = (double *)(particlesource->GetPointData()->GetScalars()->GetVoidPointer(0));
-        for (int i=0; i<N; i++)
-        {
-          newdata[i*4 + 0] = static_cast<unsigned char>(bmpdata[i]);
-          newdata[i*4 + 1] = static_cast<unsigned char>(bmpdata[i]);
-          newdata[i*4 + 2] = static_cast<unsigned char>(bmpdata[i]);
-          double temp = bmpdata[i];
-          if (temp>255) temp = 255;
-          newdata[i*4 + 3] = static_cast<unsigned char>(std::floor(std::sqrt(temp*temp)+0.5));
-          int val = newdata[i*4 + 3];
-        }
-        break;
-      }
-      //
-      default:
-      {
-        vtkErrorMacro(<<"Can't handle this data type yet");
-        return;
-      }
-    }
-    ParticleBuildTime.Modified();
-  }
-
-  //
-  if (this->ParticleTexture == 0)
-  {
-    this->ParticleTexture = vtkOpenGLTexture::New();
-    this->ParticleTexture->RepeatOff();
-  }
-
-  this->ParticleTexture->SetInput(gaussian);
-  this->ParticleTexture->SetLookupTable(this->bmpReader->GetLookupTable());
 
-//  this->ParticleTexture->DebugOn();
-//  this->ParticleTexture->Update();
-*/
   // setup clippingplanes
   clipPlanes = this->ClippingPlanes;
   if (clipPlanes == NULL)
@@ -591,8 +515,8 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act)
   // For vertex coloring, this sets this->Colors as side effect.
   // Color arrays are cached. If nothing has changed,
   // then the scalars do not have to be regenerted.
-  this->actorOpacity = act->GetProperty()->GetOpacity();
-  this->MapScalars(this->actorOpacity);
+  this->ActorOpacity = act->GetProperty()->GetOpacity();
+  this->MapScalars(this->ActorOpacity);
 
   //
   // if something has changed regenerate colors and display lists
@@ -610,9 +534,6 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act)
       this->ReleaseGraphicsResources(ren->GetRenderWindow());
       this->LastWindow = ren->GetRenderWindow();
 
-      // Load the texture for the particle into gl
-      //this->ParticleTexture->Load(ren);
-
       // get a unique display list id
       this->ListId = glGenLists(1);
       glNewList(this->ListId,GL_COMPILE);
@@ -641,9 +562,6 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act)
     if (!this->ImmediateModeRendering &&
         !this->GetGlobalImmediateModeRendering())
       {
-      // Load the texture for the particle into gl
-      //this->ParticleTexture->Load(ren);
-
       // Time the actual drawing
       this->Timer->StartTimer();
       glCallList(this->ListId);
@@ -656,9 +574,6 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act)
   if (this->ImmediateModeRendering ||
       this->GetGlobalImmediateModeRendering())
     {
-    // Load the texture for the particle into gl
-    //this->ParticleTexture->Load(ren);
-
     // Time the actual drawing
     this->Timer->StartTimer();
     this->Draw(ren,act);
@@ -714,6 +629,14 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act)
   glEnd(); \
 }
 //-----------------------------------------------------------------------------
+float VISU_OpenGLPointSpriteMapper::GetMaximumSupportedSize()
+{
+  float maximumSupportedSize = 0.0;
+  glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maximumSupportedSize );
+
+  return maximumSupportedSize;
+}
+//-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::InitSprites()
 {
   switch (this->RenderMode)
@@ -753,25 +676,6 @@ void VISU_OpenGLPointSpriteMapper::InitSprites()
   //
   //glEnable(GL_POINT_SMOOTH);
 
-  //
-  // Get the max point size : we need it to control Point Fading
-  //
-  float CurrentPointSize = 1.0;
-  if (this->MaximumSupportedSize==0.0)
-  {
-    glGetFloatv( GL_POINT_SIZE_MAX_ARB, &this->MaximumSupportedSize );
-    //cout << this->MaximumSupportedSize << endl;
-  }
-  if (this->DefaultPointSize==-1)
-  {
-    CurrentPointSize = this->MaximumSupportedSize;
-  }
-  else
-  {
-    CurrentPointSize = this->DefaultPointSize;
-  }
-  glPointSize( CurrentPointSize );
-
   /*
   // Set Quadratic Attenuation parameters
   glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, this->QuadraticPointDistanceAttenuation );
@@ -796,6 +700,8 @@ void VISU_OpenGLPointSpriteMapper::CleanupSprites()
   glEnable( GL_DEPTH_TEST );
   glEnable( GL_LIGHTING );
   glEnable( GL_BLEND );
+
+  //glDisable( GL_VERTEX_PROGRAM_ARB );
 }
 //-----------------------------------------------------------------------------
 void VISU_OpenGLPointSpriteMapper::InitTexture( vtkImageData* imageData )
@@ -826,6 +732,7 @@ void VISU_OpenGLPointSpriteMapper::InitTexture( vtkImageData* imageData )
   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
   glEnable( GL_TEXTURE_2D );
   glEnable( GL_POINT_SPRITE_ARB );
+  //glEnable( GL_VERTEX_PROGRAM_ARB );
   glEnable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB );
   glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
   glBindTexture( GL_TEXTURE_2D, this->PointSpriteTexture );
@@ -846,6 +753,8 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx,
 
   InitSprites();
 
+  glPointSize( this->DefaultPointSize );
+
   void *voidPoints = p->GetVoidPointer(0);
   unsigned char *rgba;
   float *alphadata;
@@ -919,7 +828,7 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx,
             unsigned char *col = colors->GetPointer(pts[0]<< 2);
             if (idx & VTK_PDPSM_ALPHA_ARRAY)
             {
-              col[3] = (unsigned char)(this->actorOpacity*255.0*alphadata[pts[0]]+0.499999);
+              col[3] = (unsigned char)(this->ActorOpacity*255.0*alphadata[pts[0]]+0.499999);
             }
             glColor4ubv(col);
           }
@@ -1044,12 +953,6 @@ void VISU_OpenGLPointSpriteMapper::ReleaseGraphicsResources(vtkWindow *win)
     this->ListId = 0;
     }
   this->LastWindow = NULL;
-  // We actually only want to release our texture when the texture needs reloading, or when
-  // we are supposed to free up resources
-  if (this->ParticleTexture)
-    {
-      this->ParticleTexture->ReleaseGraphicsResources(win);
-    }
   */
 }
 //-----------------------------------------------------------------------------
index 81039239059fa1ba4854459cf839430ded0e3a89..52f7b73e7e91a506f0c723e1e486501d96d5be50 100755 (executable)
@@ -28,8 +28,6 @@
 #ifndef VISU_OpenGLPointSpriteMapper_HeaderFile
 #define VISU_OpenGLPointSpriteMapper_HeaderFile
 
-//#undef GL_ARB_shader_objects
-
 #if defined(_MSC_VER)
 # pragma warning ( disable : 4275 )
 #endif
@@ -70,16 +68,6 @@ public:
   vtkTypeRevisionMacro(VISU_OpenGLPointSpriteMapper,MAPPER_SUPERCLASS);
   virtual void PrintSelf(ostream& os, vtkIndent indent);
 
-  // Description:
-  // Specify file name of particle bitmap
-  vtkSetStringMacro(ParticleImageFileName);
-  vtkGetStringMacro(ParticleImageFileName);
-
-  // Description:
-  // Specify image object for particle bitmap
-  vtkGetObjectMacro(ParticleImage, vtkImageData);
-  virtual void SetParticleImage(vtkImageData *);
-
   // Description:
   // Specify the name of a scalar array which will be used to control
   // the alpha value of each point. The values should be between 0,1
@@ -116,13 +104,6 @@ public:
   vtkSetVector3Macro(QuadraticPointDistanceAttenuation, float);
   vtkGetVector3Macro(QuadraticPointDistanceAttenuation, float);
 
-  // Description:
-  // Return the maximum point size supported by the graphics hardware.
-  // If OpenGl has not yet been initialized, then this call will
-  // return a value of 0, otherwise it will return the value
-  // from glGetFloatv( GL_POINT_SIZE_MAX_ARB, &MaximimSupportedSize );
-  vtkGetMacro(MaximumSupportedSize, float);
-
   // Description:
   // Set/Get the RenderMode for this mapper. Currently 2 modes are supported
   // Accumulate : Uses glBlendFunc(GL_SRC_ALPHA, GL_ONE), and no depth testing
@@ -133,7 +114,7 @@ public:
   vtkSetMacro(RenderMode, int);
   vtkGetMacro(RenderMode, int);
   void SetRenderModeToAccumulate() { this->SetRenderMode(Accumulate); }
-  void SetRenderModeToOcclude()   { this->SetRenderMode(Occlude); }
+  void SetRenderModeToOcclude() { this->SetRenderMode(Occlude); }
 
   // Description:
   // Implement superclass render method.
@@ -149,66 +130,74 @@ public:
   // Draw method for OpenGL.
   virtual int Draw(vtkRenderer *ren, vtkActor *a);
 
+  // Description:
+  // Initializing texture for Point Sprites
   void InitTexture( vtkImageData* );
 
-  void SetShaderVariable( const char*, float );
+  // Description:
+  // Return the maximum point size supported by the graphics hardware.
+  float GetMaximumSupportedSize();
+
+  // Description:
+  // Point Sprite size parameters
+  vtkGetMacro(PointSpriteClamp, float);
+  vtkGetMacro(PointSpriteMinSize, float);
+  vtkGetMacro(PointSpriteMaxSize, float);
+  vtkGetMacro(PointSpriteMagnification, float);
+
+  void SetPointSpriteClamp( float );
+  void SetPointSpriteMinSize( float );
+  void SetPointSpriteMaxSize( float );
+  void SetPointSpriteMagnification( float );
 
 protected:
   VISU_OpenGLPointSpriteMapper();
   ~VISU_OpenGLPointSpriteMapper();
 
-  void DrawPoints(int idx,
-                  vtkPoints *p,
-                  vtkUnsignedCharArray *c,
-                  vtkFloatArray *alpha,
-                  vtkIdType &cellNum,
-                  int &noAbort,
-                  vtkCellArray *ca,
-                  vtkRenderer *ren);
-
-  void InitShader();
+  void              DrawPoints(int idx,
+                              vtkPoints *p,
+                              vtkUnsignedCharArray *c,
+                              vtkFloatArray *alpha,
+                              vtkIdType &cellNum,
+                              int &noAbort,
+                              vtkCellArray *ca,
+                              vtkRenderer *ren);
 
-  void InitExtensions();
+  void              InitExtensions();
 
-  void InitSprites();
-  void CleanupSprites();
+  void              InitSprites();
+  void              CleanupSprites();
 
-  vtkIdType TotalCells;
+  vtkIdType         TotalCells;
 
   int               ListId;
   int               ExtensionsInitialized;
   int               ExtensionsOK;
-  vtkBMPReader     *bmpReader;
-  vtkOpenGLTexture *ParticleTexture;
-  vtkImageData     *ParticleImage;
-  char             *ParticleImageFileName;
   char             *AlphaChannelArray;
-  double            actorOpacity; 
+  double            ActorOpacity; 
   char             *SizeChannelArray;
   float             DefaultPointSize;
-  float             MaximumSupportedSize;
   float             QuadraticPointDistanceAttenuation[3];
-  vtkTimeStamp      ParticleBuildTime;
-  vtkImageData     *gaussian;
   int               RenderMode;
 
 #ifdef GL_ARB_shader_objects
-  void*             OpenGLLibrary;
-
-  GLhandleARB       VertexShader;
-  GLhandleARB       VertexProgram;
+  GLhandleARB       InitShader();
+  void              PrintInfoLog( GLhandleARB );
+  void              SetShaderVariable( const char* variable, float value );
 
-  void              printInfoLog( GLhandleARB );
+  static GLhandleARB VertexProgram;
+  void*             OpenGLLibrary;
 #endif
 
+  float             PointSpriteClamp;
+  float             PointSpriteMinSize;
+  float             PointSpriteMaxSize;
+  float             PointSpriteMagnification;
+
   vtkXMLImageDataReader* XMLImageDataReader;
   GLuint            PointSpriteTexture;
 
   bool              IsUsingOpenGLMapper;
-
-private:
-  VISU_OpenGLPointSpriteMapper(const VISU_OpenGLPointSpriteMapper&);  // Not implemented.
-  void operator=(const VISU_OpenGLPointSpriteMapper&);  // Not implemented.
 };
 
 #endif