Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help to draw a dashed line in OpenGl

I am trying to draw a dashed line in OpenGl using a texture equally spaced along the path as the dashes. I can get a solid line, but that wont work for this project. Could someone help point me in the right direction?

like image 293
user661855 Avatar asked Mar 16 '11 04:03

user661855


People also ask

How do you use dashed lines?

A dash is a little horizontal line that floats in the middle of a line of text (not at the bottom: that's an underscore). It's longer than a hyphen and is commonly used to indicate a range or a pause. Dashes are used to separate groups of words, not to separate parts of words like a hyphen does.

What is dash dotted line?

The dashed or dotted line is known to diminish the boundary strength of an object, reducing its salience, which is one reason we interpret it as “lesser” than an object with a solid line. When you see a speech bubble outlined with a dashed line, you might interpret it as a whisper or an “off-stage” comment.


1 Answers

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();

0xAAAA is the parameter you want to experiment with.

(Sourced from here)

like image 129
visakh7 Avatar answered Oct 05 '22 22:10

visakh7