Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Thick dashed lines

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    7

    Thick dashed lines

    Hello!

    I'm writing a function that draws thick dashed lines with OpenGL. After great efforts I have ensured that the geometry of the texture suits well to the line (drawn with triangle strips).


    However, I find no way to change how often the texture is repeated. The texture (see the attached image) is 4 pixels wide by 8 high. I want each pixel to be displayed wider so that the line look better.


    Any idea?
    Thank you!
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	dashed.jpg 
Views:	205 
Size:	83.6 KB 
ID:	1048  

  2. #2
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    17
    I'm not sure what you specifically want, but the repeat factor would probably be the line length divided by the stipple length.

    If you want to emulate OpenGL's glLineStipple for thick lines, then they use a 16-bit pattern.
    You can generate a 1D texture for your stipple texture, and map it onto your line geometry using the repeat factor as texture coordinates.

    I'm sure if you Google for "1D texture" and "stipple" you'll find a better explanation of it.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    7
    Thanks, sevenfold, for your answer. I'll explain myself better: I need very thick lines, so I cannot use glLineWidth nor stippling. Therefore, I build the tri-strip geometry and I render it mapping a texture onto it. I also need dashed lines (as you can see in the attached picture to my 1st post). My approach is to use a 2D texture with "holes" (one of two colors has alpha zero).

    The first problem is calculating the texture mapping that is to be applied using glTexCoord2f(). This problem is solved, as you can see in the picture.

    The second problem: take a look to the picture attached to this post: I'm getting the four colour texture as in the right segment; I'd like to stretch it as in the left one. So it seems I should instruct OpenGL to "widen" (excuse my poor english) or stretch the texture along the tri-strip.

    Thanks again!

    Click image for larger version. 

Name:	dashed2.jpg 
Views:	83 
Size:	54.9 KB 
ID:	1049

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    7
    I got it!

    The trick is using glMatrixMode(GL_TEXTURE)

    Thanks a lot!

Posting Permissions

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