[vtk-developers] Gradient backgrounds in vtkRenderer.

Goodwin Lawlor goodwin.lawlor at ucd.ie
Mon Apr 7 16:48:47 EDT 2008


Hi Jeff,

I had a tcl script doing something similar but it suffered from the 
foreground actor disappearing whenever its opacity was < 1.0

http://www.bioengineering-research.com/vtk/BackgroundGradient.tcl

Don't know if this "bug" bites your implementation below or not... I 
hope not - its a nice addition to give a sense of depth to the render 
window.

Goodwin

Jeff Baumes wrote:
> 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);
>       }
>     }
>
>   




More information about the vtk-developers mailing list