Answer the question
In order to leave comments, you need to log in
How to draw thick dashed lines in OpenGL?
I am using triangulation to draw thick lines. Each segment turns into a rectangle consisting of two triangles.
Next, in order to add a dotted line, I create a texture from a single alpha channel that describes the pattern. To prevent the pattern from starting over on each segment, I calculate the lineSoFar parameter (the length of the line from the beginning), which essentially acts as a texture coordinate. In the fragment shader I use the value of the alpha channel to determine where the dash is and where the gap is.
float a = texture2D(u_tex, v_normal/u_tex_len).a;
gl_FragColor = u_color*a;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question