To main page | 3dengine.org

Drawing dotted lines (OpenGL)


Dotted or dashed line in OpenGL is called stippled.
glPushAttrib(GL_ENABLE_BIT); 
# glPushAttrib is done to return everything to normal after drawing

glLineStipple(1, 0xAAAA);  # [1]
glEnable(GL_LINE_STIPPLE);
glBegin(GL_LINES);
glVertex3f(-.5,.5,-.5);
glVertex3f(.5,.5,-.5);
glEnd();

glPopAttrib();

[1] 0xAAAA is the parameter you want to experiment with.