Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Another member mentioned an issue while drawing arcs with GL_LINE_STRIP. He has GL_LINE_SMOOTH enabled.

The question is, how could he avoid the tiny gaps between vertices without increasing their number?

Drawing curves issue

Edit: The original discussion was on SO. Click here for more info.

Thanks in advance!

share|improve this question
@vulpix Excuse my typos, it's 1:00 am here, cheers! – gifnoc-gkp Aug 14 '13 at 21:10
Cross posting another someone else's question? That's a new one. – Byte56 Aug 14 '13 at 23:18
@Byte56 Is there a problem? I found it really interesting since there's no solution anywhere. The interpolation opelgl does internally doesn't produce the expected result when AA and Multisampling is on! – gifnoc-gkp Aug 14 '13 at 23:21
OpenGL lines are pretty much broken as designed; they work fine as long as you know what you're doing (i.e, debug output, lines that don't need to be 1:1 with what you expect, etc). If you want to do any serious work, use polygons. – Jari Komppa Aug 15 '13 at 10:22
@JariKomppa Alright, thanks for the tip. – gifnoc-gkp Aug 15 '13 at 10:23
up vote 3 down vote accepted

A quick google search shows this to be a common problem with line strips. I strongly suspect the correct answer is: don't use line strips. Use triangles instead, and build your own geometry so that it doesn't have gaps.

Moreover, according to this answer on StackOverflow, it sounds like line rendering is not rigidly specified by the OpenGL spec the way triangle rendering is, so results might vary between GPU vendors, chipsets, and driver versions.

share|improve this answer
From the link you provided: If you want to guarantee connected lines with no gaps or overlaps, you should render with GL_LINE_LOOP (or GL_LINE_STRIP for a connected series that does not end where it starts) instead of GL_LINES. – gifnoc-gkp Aug 14 '13 at 21:30
@TheOtherGuy Yeah, but if you continue searching, you'll find that lots of people have this exact problem with GL_LINE_LOOP and GL_LINE_STRIP. So I don't think that last sentence is correct. – Nathan Reed Aug 14 '13 at 21:32
Maybe it's something else? – gifnoc-gkp Aug 14 '13 at 21:32

This isn't a problem with line strips. OpenGL is doing exactly what you have asked it to do: draw a bunch of rectangles oriented to match the 'lines' you've provided, each with a particular width which you've also provided.

The problem is that you're imagining that OpenGL is going to magically join up the corners of those rectangles into a single swooping shape. That simply isn't going to happen -- OpenGL has no way to determine where those merged vertices ought to be placed, whether you want them at an averaged position or maintaining a particular orientation or distance apart or what. It just draws a rectangle for each line segment, with those rectangles oriented along the direction of the line. A "line strip" isn't a compound line from OpenGL's point of view; it's just a list of discrete lines which is expressed using less data. Because that's all it can be, because OpenGL can't guess what you want it to do.

If you want to draw a wide smoothly curving shape like this, you need to build the geometry for it yourself, and render it using triangles.

share|improve this answer
Spatial anti aliasing is supposed to smoothen it, but it doesn't. That's the issue! – gifnoc-gkp Aug 15 '13 at 0:01
No. Anti-aliasing (when supported by the driver, which it doesn't have to be) anti-aliases the rectangles produced. It does not magically join together the rectangle corners. It's designed for anti-aliasing single-pixel-width lines. – Trevor Powell Aug 15 '13 at 0:07
"OpenGL has no way to determine where those merged vertices ought to be placed" - well, in the case of GL_LINE_STRIP and GL_LINE_LOOP it certainly could generate joined corners if that were specified and implemented. It wouldn't be "magic" to do so, it's just not how it's actually designed. See also NV_path_rendering. – Nathan Reed Aug 15 '13 at 0:14
@NathanReed RE: "if that were specified and implemented" -- Absolutely. But those things are not present today, and so really aren't relevant to this question. With the data currently available to it, OpenGL cannot join up those corners by itself in a way which would always work for everyone. – Trevor Powell Aug 15 '13 at 1:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.