[vtk-developers] OpenGL Line Stippling support ?
Sebastien BARRE
sebastien at barre.nom.fr
Mon Jan 22 12:43:39 EST 2001
At 22/01/2001 08:56, Will Schroeder wrote:
>I think it would be a nice addition. The only minor concern is whether
>this could be supported by other rendering libraries.
OK, done.
The problem is that OpenGL is kind of very "specific" in the way it handles
line stippling. The relevant API call is :
glEnable (GL_LINE_STIPPLE);
glLineStipple (factor, pattern);
where "pattern" is a 16-bit binary pattern (1 = pixel on, 0 = pixel off),
and "factor" specifies how many times each bit in the pattern is to be
repeated.
Thus, I've added the following settings to vtkProperty and vtkProperty2D
(and modified vtkOpenGLProperty and vtkOpenGLPolyDataMapper2D accordingly).
// Set/Get the stippling pattern of a Line, as a 16-bit binary pattern
// (1 = pixel on, 0 = pixel off).
// This is only implemented for OpenGL. The default is 0xFFFF.
vtkSetMacro(LineStipplePattern,int);
vtkGetMacro(LineStipplePattern,int);
// Description:
// Set/Get the stippling repeat factor of a Line, which specifies how
// many times each bit in the pattern is to be repeated.
// This is only implemented for OpenGL. The default is 1.
vtkSetClampMacro(LineStippleRepeatFactor,int,1,VTK_LARGE_INTEGER);
vtkGetMacro(LineStippleRepeatFactor,int);
I've added the graphics/exampleTcl/TestLineStipple.tcl script, an extended
version of the squadViewer, where you can change the repeat factor and the
pattern *interactively*, and watch the resulting line aspect.
Feel free to tell me if this interface is too specific, although we already
have OpenGL specific functions in vtkProperty (LineWidth, PointSize). The
problem is (as you stated) that this pattern and repeat factor might not
have direct equivalent in the other rendering libraries. On the other hand,
if you play with the testing script, you will see that an abstract
interface like SetLineStyleToPlain or SetLineStyleToDash provides less
control and will not guarantee that the line will look "dashed".
Just my 2 cents. Any other compromise is welcome, of course.
More information about the vtk-developers
mailing list