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 7 of 7

Thread: How to draw a smooth thick polyline?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2018
    Posts
    4

    Question How to draw a smooth thick polyline?

    Greetings:

    I am New here, and trying to render a round-capped 2D polyline in 3D space.

    I'd tried glEnable(GL_LINES);
    & glEnable(GL_LINE_SMOOTH);
    then set the line_width and rendered.

    Unfortunately, it return a 3D polyline, and there are not any capping between tow segments.

    How do I solve the problem? Any help is appreciated.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,003
    OpenGL doesn't do joins or caps. A "polyline" rendered with GL_LINE_STRIP or GL_LINE_LOOP is no different to rendering the individual line segments separately.

    If you want joins or caps, you'll need to render them yourself.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2018
    Posts
    4
    Quote Originally Posted by GClements View Post
    OpenGL doesn't do joins or caps. A "polyline" rendered with GL_LINE_STRIP or GL_LINE_LOOP is no different to rendering the individual line segments separately.

    If you want joins or caps, you'll need to render them yourself.
    Ok, I see.

    So, I have to write my own geometry shader, right?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,003
    Quote Originally Posted by ozymandias View Post
    So, I have to write my own geometry shader, right?
    If you want GL_LINE_STRIP to do joins or caps, you'll need a geometry shader which generates triangles. Alternative approaches include conversion to triangles in the application or drawing points at the vertices with a separate draw call.

  5. #5
    Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    394
    I have used the method of drawing points at the vertices (suggested by GClements) to good effect.
    You will want to use point and line smoothing for best results.

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2018
    Posts
    4
    Quote Originally Posted by GClements View Post
    If you want GL_LINE_STRIP to do joins or caps, you'll need a geometry shader which generates triangles. Alternative approaches include conversion to triangles in the application or drawing points at the vertices with a separate draw call.
    O.K. I will try.

    Thank you very much for explanation

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2018
    Posts
    4
    Quote Originally Posted by Carmine View Post
    I have used the method of drawing points at the vertices (suggested by GClements) to good effect.
    You will want to use point and line smoothing for best results.
    thank you for the suggestions~~

Posting Permissions

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