title: Is it possible to anti-alias line ends in OpenGL?
body: <p>I'm drawing some 2D lines in OpenGL (using the AGL API). I've turned on line anti-aliasing using <code>GL_LINE_SMOOTH</code> and I've set <code>GL_LINE_SMOOTH_HINT</code> to <code>GL_NICEST</code>.</p>
  <p>So for example, here's a magnified view of a diagonal line<sup>*</sup>:</p>
  <p><a href="https://i.stack.imgur.com/U1l1r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U1l1r.png" alt="Line with anti-aliased edges" /></a><br />
  <sub>(source: <a href="http://whileyouweregone.co.uk/images/stackoverflow/good-aa.png" rel="nofollow noreferrer">whileyouweregone.co.uk</a>)</sub></p>
  <p>However, the problem is that my code draws some shapes which are built up of large numbers of vertical lines, and it seems the end points of lines are <em>not</em> anti-aliased. Here's one of those:</p>
  <p><a href="https://i.stack.imgur.com/nnSTI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nnSTI.png" alt="Lines without anti-aliased endpoints" /></a><br />
  <sub>(source: <a href="http://whileyouweregone.co.uk/images/stackoverflow/bad-aa.png" rel="nofollow noreferrer">whileyouweregone.co.uk</a>)</sub></p>
  <p>(Each step you can see is made up of 10 vertical lines, with the x coordinates of each line incrementing in steps of 1.0, and the y coordinates incrementing in steps of 0.1.)</p>
  <p>Is there a way of getting OpenGL to also anti-alias the lines' end points?</p>
  <p><strong>Edit:</strong></p>
  <p>As per <a href="https://stackoverflow.com/questions/7793349/is-it-possible-to-anti-alias-line-ends-in-opengl/7793417#7793417">Calvin1602's answer</a>, I've tried removing the <code>GL_LINE_SMOOTH</code> stuff and am instead enabling MSAA by adding the following to my AGL attributes array:</p>
  <p><code>AGL_SAMPLE_BUFFERS_ARB, 1, AGL_SAMPLES_ARB, 4, AGL_MULTISAMPLE</code></p>
  <p>...and calling:</p>
  <p><code>glEnable(GL_MULTISAMPLE_ARB);</code></p>
  <p>However, I still have the same problem. The line edges are anti-aliased (in a slightly different way), but the end-points aren't.</p>
  <p><sub>* Screenshots are from a Mac Pro running OS X 10.7.1 with a ATI Radeon HD 5770 1024 MB.</sub></p>
  <p><strong>Edit 2:</strong></p>
  <p>Using MSAA doesn't work for me, but simply drawing all my lines as very thin rectangles <a href="https://stackoverflow.com/questions/7793349/is-it-possible-to-anti-alias-line-ends-in-opengl/7793410#7793410">as suggested by ltjax</a> seems to have done the trick. (I didn't need to use a texture or a gradient.)</p>