[vtk-developers] Backface culling wireframe and point representations

Goodwin Lawlor goodwin.lawlor at ucd.ie
Fri Feb 27 11:55:35 EST 2004


Hi All,

I've had some code for backface culling triangles/triangle strips in
wireframe and points representations that I've just updated for the
recent changes to vtkOpenGLPolyDataMapper for doubles. It usefull for
exporting vector graphics with vtkGL2PSExporter of a model with edge
visibility. Its passed through the regression testing without a hitch
(Common/PrintSelfCheck failed though).

Presently, VTK draws lines in wireframe mode. This code works by drawing
triangles in wireframe mode and using glPolygonMode(GL_FRONT, GL_LINE)
to switch the representation. The drawback is that its slower to render
triangles than lines, so it may be quicker to render a model in
wireframe with BackfaceCullingOff than with BackfaceCullingOn (it
depends a lot on your graphics card)... It doesn't effect the
performance of any surface representation or wireframe representation
with BackfaceCullingOff.

The diffs for vtkOpenGLPolyDataMapper.cxx and and vtkOpenGLProperty.cxx
are below. You can get the modified files here:
http://www.bioengineering-research.com/vtk/vtkOpenGLProperty.cxx
http://www.bioengineering-research.com/vtk/vtkOpenGLPolyDataMapper.cxx


I'd appreciate if the powers-that-be would consider adding the changes
into cvs.

Thanks,

Goodwin

PS thanks to John Biddiscombe who originally tested the code.

RCS file: /cvsroot/VTK/VTK/Rendering/vtkOpenGLPolyDataMapper.cxx,v
retrieving revision 1.92
diff -r1.92 vtkOpenGLPolyDataMapper.cxx
1640c1640
< if (rep == VTK_POINTS)
---
> if (rep == VTK_POINTS && !prop->GetBackfaceCulling() && 
> !prop->GetFrontfaceCulling() )
1645c1645
< else if (rep == VTK_WIREFRAME)
---
> else if (rep == VTK_WIREFRAME && !prop->GetBackfaceCulling() && 
> !prop->GetFrontfaceCulling())
1662c1662
< if (rep == VTK_POINTS)
---
> if (rep == VTK_POINTS && !prop->GetBackfaceCulling() && 
> !prop->GetFrontfaceCulling() )
1667c1667
< else if (rep == VTK_WIREFRAME)
---
> else if (rep == VTK_WIREFRAME && !prop->GetBackfaceCulling() && 
> !prop->GetFrontfaceCulling())


------------------------------------


RCS file: /cvsroot/VTK/VTK/Rendering/vtkOpenGLProperty.cxx,v
retrieving revision 1.29
diff -r1.29 vtkOpenGLProperty.cxx
67a68
>     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
72a74,85
>     if (this->GetRepresentation() == VTK_WIREFRAME)
>       {
>       glPolygonMode(GL_FRONT, GL_LINE); 
>       }
>     else if (this->GetRepresentation() == VTK_SURFACE)
>       {
>       glPolygonMode(GL_FRONT, GL_FILL);
>       }
>     else
>       {
>       glPolygonMode(GL_FRONT, GL_POINT);
>       }
77a91,102
>     if (this->GetRepresentation() == VTK_WIREFRAME)
>       {
>       glPolygonMode(GL_BACK, GL_LINE);
>       }  
>     else if (this->GetRepresentation() == VTK_SURFACE)
>       {
>       glPolygonMode(GL_BACK, GL_FILL);
>       }
>     else
>       {
>       glPolygonMode(GL_BACK, GL_POINT);
>       }




More information about the vtk-developers mailing list