Results 1 to 6 of 6

Thread: Best way to convert line into triangle strip

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    3

    Best way to convert line into triangle strip

    Hiya,

    Is there an accepted best/most efficient algorithm to convert a line into a triangle strip? My reason for asking is that I'd like a to draw a 3d polyline with a specified thickness as efficiently as possible. The default opengl line primitive is limited to a thickness of 10 pixels, which isn't okay for my particular application.


    Regards,

    Pris

  2. #2
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: Best way to convert line into triangle strip

    If you want to draw it as efficiently as possible don't convert to a triangle strip - convert to indexed triangles instead.

  3. #3
    Senior Member Regular Contributor imported_tksuoran's Avatar
    Join Date
    Mar 2008
    Location
    Cambridge, UK
    Posts
    223

    Re: Best way to convert line into triangle strip

    A while back I implemented wide lines using a geometry shader. Geometry shader does clipping and viewport transformation and creates a quad / two triangles surrounding each line primitive. Fragment shader computes distance to line segment from the fragment and outputs alpha for line end rounding: Enable alpha to coverage and you will get nice round line ends.

    http://neure.ath.cx/wideline.html

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    3

    Re: Best way to convert line into triangle strip

    Thank you to both for the input.

    mhagain -- I'll do this, thanks.

    tksuoran -- the example's helpful, but I don't think using geo/fragment shaders is a good idea for my use case. I want cross platform support to maintain compatibility with older versions of OpenGL/ES.

    I was mainly looking for an efficient way to take a poly line made up of point data like so,



    And adding a uniform thickness to it, then converting it to standard primitives that would render quickly.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Los Angeles
    Posts
    374

    Re: Best way to convert line into triangle strip

    You can start by replacing each line segment with a rectangle of your desired thickness. Since you want very thick lines, this will leave you cracks at the vertices. Is that o.k.? Have you thought about what you want the vertices to look like once they are connected by thick lines?
    Am I doing your homework for you?

  6. #6
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    3

    Re: Best way to convert line into triangle strip

    Hi MaxH,

    Thanks for the reply. I'm trying to draw roads using their centerline and a given width parameter. The roads need to be a solid (don't necessarily need a thickness, but they need to be filled in). The first step I've taken is offsetting a given centerline based on the normal to a line segment in the polyline. Here's the result rendered as a GL_LINE_STRIP for clarity:



    So now I'd like to convert that into a set of triangles, or a triangle strip, or whatever primitive will let me give the surface a color or texture, as efficiently as possible. I'm not really sure how to do that though.

    * The uneven width in the image is an artifact due to some precision issues I introduced -- the lines are calculated to preserve the same width throughout.

Similar Threads

  1. Triangle Strip - Per Triangle color
    By Aliii in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-27-2013, 10:14 AM
  2. Help with Triangle strip
    By Jeffg in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-30-2010, 09:52 AM
  3. triangle strip with a LINE triangle display error
    By Samme in forum OpenGL: Windows
    Replies: 22
    Last Post: 11-20-2008, 07:50 PM
  4. Triangle Strip
    By Cosmosis in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-12-2007, 02:55 PM
  5. Triangle Strip!
    By golgoth13 in forum OpenGL: Basic Coding
    Replies: 14
    Last Post: 03-08-2006, 06:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean