[vtk-developers] Gradient backgrounds in vtkRenderer.
Jeff Baumes
jeff.baumes at kitware.com
Mon Apr 7 16:24:18 EDT 2008
In certain applications, gradient backgrounds can add to the quality
of a visualization (in particular in information visualization). Does
anyone object to the addition of a top-to-bottom gradient in
vtkRenderer (by default it is disabled, of course)?
This involves adding the following functions to vtkViewport:
vtkSetVector3Macro(Background2,double);
vtkGetVector3Macro(Background2,double);
vtkSetMacro(GradientBackground,bool);
vtkGetMacro(GradientBackground,bool);
vtkBooleanMacro(GradientBackground,bool);
And the following to vtkOpenGLRenderer:
if (!this->Transparent() && this->GradientBackground)
{
GLboolean is_depth_en = glIsEnabled(GL_DEPTH_TEST);
GLboolean is_light_en = glIsEnabled(GL_LIGHTING);
if (is_depth_en)
{
glDisable(GL_DEPTH_TEST);
}
if (is_light_en)
{
glDisable(GL_LIGHTING);
}
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
{
glLoadIdentity ();
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
{
glLoadIdentity ();
glBegin(GL_QUADS);
//first Vertex (-1, -1)
glColor3dv(this->Background);
glVertex2f(-1.0, -1.0);
//second vertex
glColor3dv(this->Background);
glVertex2f(1.0, -1.0);
//third vertex
glColor3dv(this->Background2);
glVertex2f(1.0, 1.0);
//fourth vertex
glColor3dv(this->Background2);
glVertex2f(-1.0, 1.0);
glEnd();
}
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
glPopMatrix();
if (is_depth_en)
{
glEnable(GL_DEPTH_TEST);
}
if (is_light_en)
{
glEnable(GL_LIGHTING);
}
}
--
Jeff Baumes, Ph.D.
R&D Engineer, Kitware Inc.
(518) 371-3971 x132
jeff.baumes at kitware.com
More information about the vtk-developers
mailing list