#include <vtkMatrix4x4.h>
#include <vtkObjectFactory.h>
#include <vtkOpenGLRenderer.h>
-#include <vtkPlane.h>
-#include <vtkPlaneCollection.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolygon.h>
this->ExtensionsOK = 0;
this->AlphaChannelArray = NULL;
this->SizeChannelArray = NULL;
- this->DefaultPointSize = 50.0;
+ this->DefaultPointSize = 30.0;
this->QuadraticPointDistanceAttenuation[0] = 1.0;
this->QuadraticPointDistanceAttenuation[1] = 0.0;
this->QuadraticPointDistanceAttenuation[2] = 0.0;
this->OpenGLLibrary = 0;
#endif
+ this->UsePointSprites = true;
+ this->UseTextures = true;
+ this->UseShader = true;
+
this->PointSpriteClamp = 100.0;
this->PointSpriteSize = 0.0;
this->PointSpriteMinSize = 15.0;
*/
#ifdef GL_ARB_shader_objects
- //if( !VISU_OpenGLPointSpriteMapper::VertexProgram )
+ if( this->UseShader )
{
- this->OpenGLLibrary = dlopen( "libGL.so", RTLD_LAZY );
- VISU_OpenGLPointSpriteMapper::VertexProgram = this->InitShader();
- }
+ //if( !VISU_OpenGLPointSpriteMapper::VertexProgram )
+ {
+ this->OpenGLLibrary = dlopen( "libGL.so", RTLD_LAZY );
+ VISU_OpenGLPointSpriteMapper::VertexProgram = 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( "geomSize", this->PointSpriteSize );
- this->SetShaderVariable( "minSize", this->PointSpriteMinSize );
- this->SetShaderVariable( "attrib4", 1.0 );
- this->SetShaderVariable( "maxSize", this->PointSpriteMaxSize );
- this->SetShaderVariable( "magnification", this->PointSpriteMagnification );
+ 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( "geomSize", this->PointSpriteSize );
+ this->SetShaderVariable( "minSize", this->PointSpriteMinSize );
+ this->SetShaderVariable( "attrib4", 1.0 );
+ this->SetShaderVariable( "maxSize", this->PointSpriteMaxSize );
+ this->SetShaderVariable( "magnification", this->PointSpriteMagnification );
+ }
#endif
this->ExtensionsOK = 1;
vtkIdType numPts;
vtkPolyData *input= this->GetInput();
- vtkPlaneCollection *clipPlanes;
- vtkPlane *plane;
- int i, numClipPlanes;
- double planeEquation[4];
//
// make sure that we've been properly initialized
//
if (ren->GetRenderWindow()->CheckAbortStatus())
- {
return;
- }
if ( input == NULL )
- {
+ {
vtkErrorMacro(<< "No input!");
return;
- }
+ }
else
- {
+ {
this->InvokeEvent(vtkCommand::StartEvent,NULL);
input->Update();
this->InvokeEvent(vtkCommand::EndEvent,NULL);
numPts = input->GetNumberOfPoints();
- }
+ }
if (numPts == 0)
- {
+ {
vtkDebugMacro(<< "No points!");
return;
- }
+ }
if ( this->LookupTable == NULL )
- {
this->CreateDefaultLookupTable();
- }
// make sure our window is current
ren->GetRenderWindow()->MakeCurrent();
- // setup clippingplanes
- clipPlanes = this->ClippingPlanes;
- if (clipPlanes == NULL)
- {
- numClipPlanes = 0;
- }
- else
- {
- numClipPlanes = clipPlanes->GetNumberOfItems();
- if (numClipPlanes > 6)
- {
- vtkErrorMacro(<< "OpenGL guarantees at most 6 additional clipping planes");
- }
- }
-
- for (i = 0; i < numClipPlanes; i++)
- {
- glEnable((GLenum)(GL_CLIP_PLANE0+i));
- }
-
- if ( clipPlanes )
- {
- vtkMatrix4x4 *actorMatrix = vtkMatrix4x4::New();
- act->GetMatrix( actorMatrix );
- actorMatrix->Invert();
-
- float origin[4], normal[3], point[4];
-
- for (i = 0; i < numClipPlanes; i++)
- {
- plane = (vtkPlane *)clipPlanes->GetItemAsObject(i);
-
- plane->GetOrigin(origin);
- plane->GetNormal(normal);
-
- point[0] = origin[0] + normal[0];
- point[1] = origin[1] + normal[1];
- point[2] = origin[2] + normal[2];
-
- origin[3] = point[3] = 1.0;
-
- actorMatrix->MultiplyPoint( origin, origin );
- actorMatrix->MultiplyPoint( point, point );
-
- if ( origin[3] != 1.0 )
- {
- origin[0] /= origin[3];
- origin[1] /= origin[3];
- origin[2] /= origin[3];
- }
-
- if ( point[3] != 1.0 )
- {
- point[0] /= point[3];
- point[1] /= point[3];
- point[2] /= point[3];
- }
-
- normal[0] = point[0] - origin[0];
- normal[1] = point[1] - origin[1];
- normal[2] = point[2] - origin[2];
-
- planeEquation[0] = normal[0];
- planeEquation[1] = normal[1];
- planeEquation[2] = normal[2];
- planeEquation[3] = -(planeEquation[0]*origin[0]+
- planeEquation[1]*origin[1]+
- planeEquation[2]*origin[2]);
- glClipPlane((GLenum)(GL_CLIP_PLANE0+i),planeEquation);
- }
-
- actorMatrix->Delete();
- }
-
// 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->MapScalars(this->ActorOpacity);
// Initializing the texture for Point Sprites
- this->InitTexture();
+ if( this->UseTextures )
+ this->InitTextures();
//
// if something has changed regenerate colors and display lists
input->GetMTime() > this->BuildTime ||
act->GetProperty()->GetMTime() > this->BuildTime ||
ren->GetRenderWindow() != this->LastWindow)
- {
+ {
if (!this->ImmediateModeRendering &&
!this->GetGlobalImmediateModeRendering())
- {
+ {
this->ReleaseGraphicsResources(ren->GetRenderWindow());
this->LastWindow = ren->GetRenderWindow();
this->Timer->StartTimer();
glCallList(this->ListId);
this->Timer->StopTimer();
- }
+ }
else
- {
+ {
this->ReleaseGraphicsResources(ren->GetRenderWindow());
this->LastWindow = ren->GetRenderWindow();
- }
+ }
if (noAbort)
- {
this->BuildTime.Modified();
- }
- }
+ }
// if nothing changed but we are using display lists, draw it
else
- {
+ {
if (!this->ImmediateModeRendering &&
!this->GetGlobalImmediateModeRendering())
- {
+ {
// Time the actual drawing
this->Timer->StartTimer();
glCallList(this->ListId);
this->Timer->StopTimer();
- }
}
+ }
// if we are in immediate mode rendering we always
// want to draw the primitives here
if (this->ImmediateModeRendering ||
this->GetGlobalImmediateModeRendering())
- {
+ {
// Time the actual drawing
this->Timer->StartTimer();
this->Draw(ren,act);
this->Timer->StopTimer();
- }
-
- //this->Texture->Render( ren );
+ }
this->TimeToDraw = (float)this->Timer->GetElapsedTime();
// If the timer is not accurate enough, set it to a small
// time so that it is not zero
if ( this->TimeToDraw == 0.0 )
- {
this->TimeToDraw = 0.0001;
- }
-
- for (i = 0; i < numClipPlanes; i++)
- {
- glDisable((GLenum)(GL_CLIP_PLANE0+i));
- }
}
//-----------------------------------------------------------------------------
float VISU_OpenGLPointSpriteMapper::GetMaximumSupportedSize()
return maximumSupportedSize;
}
//-----------------------------------------------------------------------------
-void VISU_OpenGLPointSpriteMapper::InitSprites()
+void VISU_OpenGLPointSpriteMapper::InitPointSprites()
{
glEnable( GL_POINT_SPRITE_ARB );
glEnable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB );
*/
}
//-----------------------------------------------------------------------------
-void VISU_OpenGLPointSpriteMapper::CleanupSprites()
+void VISU_OpenGLPointSpriteMapper::CleanupPointSprites()
{
// Set GL params back to normal to stop other vtkMappers diusplaying wrongly
glEnable( GL_BLEND );
//-----------------------------------------------------------------------------
-void VISU_OpenGLPointSpriteMapper::InitTexture()
+void VISU_OpenGLPointSpriteMapper::InitTextures()
{
- //cout << "VISU_OpenGLPointSpriteMapper::InitTexture " << this->GetImageData() << endl;
+ //cout << "VISU_OpenGLPointSpriteMapper::InitTextures " << this->GetImageData() << endl;
if( !this->GetImageData() )
return;
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, aSize[0], aSize[1], 0,
GL_RGBA, GL_UNSIGNED_BYTE, dataPtr );
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ //glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable( GL_TEXTURE_2D );
glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
glBindTexture( GL_TEXTURE_2D, this->PointSpriteTexture );
{
//cout << "VISU_OpenGLPointSpriteMapper::DrawPoints" << endl;
- this->InitSprites();
- //this->InitTexture();
+ if( this->UsePointSprites )
+ this->InitPointSprites();
glPointSize( this->DefaultPointSize );
glDisableClientState(GL_VERTEX_ARRAY);
#endif
- /*
- glBegin( GL_POINTS );
-
- vtkIdType *pts = 0;
- vtkIdType npts = 0;
- unsigned short count = 0;
- for( cells->InitTraversal(); cells->GetNextCell( npts, pts ); count++ )
- {
- if (colors)
- {
- unsigned char *col = colors->GetPointer(pts[0]<< 2);
- glColor4ubv(col);
- }
-
- glVertex3fv(p->GetPoint(pts[0]));
-
- }
- glEnd();
- */
- this->CleanupSprites();
+ if( this->UsePointSprites )
+ this->CleanupPointSprites();
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::ReleaseGraphicsResources(vtkWindow *win)
{
this->Superclass::ReleaseGraphicsResources(win);
- /*
+
if (this->ListId && win)
{
win->MakeCurrent();
this->ListId = 0;
}
this->LastWindow = NULL;
- */
}
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::PrintSelf(ostream& os, vtkIndent indent)