From: ouv Date: Wed, 5 Oct 2005 11:53:45 +0000 (+0000) Subject: working with vertex program corrected X-Git-Tag: BR-D5-38-2003_D2005-12-10~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=82840179b516e2ca4981184c1cdab31fe361057c;p=modules%2Fvisu.git working with vertex program corrected --- diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index 5e67af59..9f651445 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -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(); } diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx index 848070cd..5d624624 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx @@ -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;