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

Thread: Drawing lines, where are they actually drawn

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2011
    Location
    Surrey
    Posts
    28

    Drawing lines, where are they actually drawn

    What is the general rule for predicting how opengl draws lines? If i draw a line from say 0,0 to 0,10 with a thickness of 2 does it get the thickness by drawing a rectangle -1,0 0,10 or does it draw a rectangle 0,0 1,10 (ie is it getting the thickness by drawing left or drawing right). Is this determined by the direction, ie a line in the opposite direction. Is drawn differently?

  2. #2
    Junior Member Regular Contributor
    Join Date
    May 2013
    Posts
    136
    I'm not even sure it even is standardized. The last time I played around with thicker then 1 pixel lines it drawn a square bar from start to end. So you always hat a deep corner on each angled connection of thick lines.

    Just set your thickness to something large (10-20) and you should see how your driver behaves. But I would not relay on it to be the same on all devices.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789
    The other thing to be aware of is that lines with width greater than 1 may not be supported in hardware, so they're going to be emulated in some manner. The OpenGL spec typically doesn't care how something like this may be emulated; all that matters is that (1) it behaves as if it were not emulated, and (2) it's otherwise conformant with the spec.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,828
    Quote Originally Posted by bobtedbob View Post
    What is the general rule for predicting how opengl draws lines? If i draw a line from say 0,0 to 0,10 with a thickness of 2 does it get the thickness by drawing a rectangle -1,0 0,10 or does it draw a rectangle 0,0 1,10 (ie is it getting the thickness by drawing left or drawing right). Is this determined by the direction, ie a line in the opposite direction. Is drawn differently?
    Rasterisation of lines is covered in 14.5 of the OpenGL 4.6 specification. Briefly:

    Non-antialiased wide lines are parallelograms: the result is the same as drawing multiple thin lines offset in the minor direction (i.e. in the y direction if the line is closer to horizontal than vertical, in the x direction if closer to vertical than horizontal). The exact algorithm used for rasterisation is implementation-dependent.

    Anti-aliased wide lines are rectangles, with two edges parallel to the line and the other two perpendicular.

    Also: note that line strips/loops don't have joins; there's no difference between drawing a strip/loop and drawing the individual segments separately.

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2011
    Location
    Surrey
    Posts
    28
    Thanks all, looks like for consistency I will just use thin quads (2 triangles) so I know where they are drawn

Posting Permissions

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