Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Dashed thic lines

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011

    Dashed thic lines


    I've benn googling for months but I finally surrender.
    Maybe someone here can help me.
    I'm writing a GIS (Geographic Information System). Therefore, I have to render complicated maps.

    One of the main challenges consists in drawing thick dashed lines (roads, e.g).
    Imagine a highway which is being constructed. It depends on the country, company, etc, but very often it's drawn as a discontinuous (dashed) thick line (yellow with red borders).


    Drawing a thick line is relatively easy using triangle strips.
    Applying red/yellow/red color to borders is also easy: you can draw the line twice, or you can use one-dimensional textures.

    But I can't figure out how can I achieve the discontinuity. If I use a bi-dimensional texture (half of it with alpha zero) then the problem is assigning texture coordinates. And that's a huge problem.

    Ah! I cannot use shaders (I don't even know what a shader is ;-)

    Any idea?
    Please see attached an example.

    Thanks in advance!!
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	dashed road.jpg 
Views:	117 
Size:	84.9 KB 
ID:	1033  

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Since you are using the fixed function pipeline, have you looked at polygon/line stipple? (glPolygonStipple/glLineStipple)

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2011
    Ups, isn't the title editable?. I meant "thick", of course ;-)

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2011
    Carsten newmann: Thanks for your reply. The line stippling is not useful because lines can appear very very wide in the screen when the user zooms in. And OpenGL lines, as you know, have a maximum width (in pixels).
    Last edited by jcurru; 05-24-2013 at 02:51 PM.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    And that's a huge problem.

    For GIS data and the like we actually calculate each of the line segments for the dashed lines and render the triangles for that. Let me know if you come up with a better way. It is in my plans to look at shaders to solve this problem.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jan 2004
    Have a look at the work done here: - nvidia implementation (though in opengl) here:

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts