Contents / Previous / Next


Stippled Lines

To make stippled (dotted or dashed) lines, you use the command glLineStipple() to define the stipple pattern, and then you enable line stippling with glEnable():
glLineStipple(1, 0x3F07);
glEnable(GL_LINE_STIPPLE);
glLineStipple( GLint factor, GLushort pattern );

Sets the current stippling pattern for lines. The pattern argument is a 16-bit series of 0s and 1s. The pattern 0x3F07 translates to 0011111100000111 in binary.

The pattern can be stretched out by using factor (between 1 and 255).

Line stippling must be enabled by passing GL_LINE_STIPPLE to glEnable(); it is disabled by passing the same argument to glDisable().

[IMAGE]

When a series of connected line segments is drawn between a single glBegin() and glEnd(), the pattern continues to shift as one segment turns into the next (with GL_LINES it is reset).