struct TVertex
{
- GLfloat r, g, b;
+ GLfloat r, g, b, hue;
GLfloat vx, vy, vz;
+ //GLfloat hue;
};
//-----------------------------------------------------------------------------
glLinkProgramARB( VertexProgram );
//this->PrintInfoLog( VertexProgram );
-
/*
cout << "Shader from " << fileName << endl;
for( int i = 0; i < strlen( shader ); i++ )
// (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( "results", this->PointSpriteResults );
this->SetShaderVariable( "clamp", this->PointSpriteClamp );
this->SetShaderVariable( "geomSize", this->PointSpriteSize );
- this->SetShaderVariable( "attrib4", 1.0 );
this->SetShaderVariable( "minSize", this->PointSpriteMinSize );
this->SetShaderVariable( "maxSize", this->PointSpriteMaxSize );
this->SetShaderVariable( "magnification", this->PointSpriteMagnification );
glBindTexture( GL_TEXTURE_2D, this->PointSpriteTexture );
}
+//-----------------------------------------------------------------------------
+int ComputeHue( int r, int g, int b )
+{
+ int h = 0;
+
+ int max = r;
+ int whatmax = 0;
+ if( g > max ) {
+ max = g;
+ whatmax = 1;
+ }
+ if( b > max ) {
+ max = b;
+ whatmax = 2;
+ }
+
+ int min = r;
+ if ( g < min ) min = g;
+ if ( b < min ) min = b;
+ int delta = max-min;
+
+ if( delta == 0 )
+ h = 0;
+ else if( whatmax == 0 ) {
+ if ( g >= b )
+ h = (120*(g-b)+delta)/(2*delta);
+ else
+ h = (120*(g-b+delta)+delta)/(2*delta) + 300;
+ }
+ else if( whatmax == 1 ) {
+ if ( b > r )
+ h = 120 + (120*(b-r)+delta)/(2*delta);
+ else
+ h = 60 + (120*(b-r+delta)+delta)/(2*delta);
+ }
+ else {
+ if ( r > g )
+ h = 240 + (120*(r-g)+delta)/(2*delta);
+ else
+ h = 180 + (120*(r-g+delta)+delta)/(2*delta);
+ }
+
+ //cout << h << endl;
+ return h + 1;
+}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx,
vtkPoints *p,
glUseProgramObjectARB( myVertexProgram );
- this->SetShaderVariable( "attrib1", 0.0 );
- this->SetShaderVariable( "attrib2", 0.0 );
- this->SetShaderVariable( "attrib3", 0.0 );
this->SetShaderVariable( "results", this->PointSpriteResults );
this->SetShaderVariable( "clamp", this->PointSpriteClamp );
this->SetShaderVariable( "geomSize", this->PointSpriteSize );
- this->SetShaderVariable( "attrib4", 0.0 );
this->SetShaderVariable( "minSize", this->PointSpriteMinSize );
this->SetShaderVariable( "maxSize", this->PointSpriteMaxSize );
this->SetShaderVariable( "magnification", this->PointSpriteMagnification );
aVertex[i].g = aPropertyColorGreen;
aVertex[i].b = aPropertyColorBlue;
}
+
+ aVertex[i].hue = ComputeHue( ( int )( aVertex[i].r * 255 ),
+ ( int )( aVertex[i].g * 255 ),
+ ( int )( aVertex[i].b * 255 ) );
}
GLuint aBufferObjectID = 0;
glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
- static int aDisplacement = 3*sizeof(GLfloat);
-
- glColorPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)0 );
- glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)aDisplacement );
+ glColorPointer( 4, GL_FLOAT, sizeof(TVertex), (void*)0 );
+ glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)(4*sizeof(GLfloat)) );
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);