I need to draw a smooth line in OpenGL and here is what I have done:
glEnable( GL_LINE_SMOOTH );
glEnable( GL_POLYGON_SMOOTH );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
glBegin( GL_LINE_STRIP );
for( UINT uiPoint = 0; uiPoint < iNumPoints; ++uiPoint )
{
const Coord &Node = vecPoints[uiPoint];
glVertex3f( Node.x, Node.y, Node.z );
}
glEnd();
What else I can do?
You can generate thin, screen-oriented polygons instead, and set the fragment's alpha according to the distance to the line.
Example :
a (0,1) b (0,1)
+--------------------------------------+
A | | B
----+--------------------------------------+----
| |
+--------------------------------------+
d (0,0) c (0,0)
Suppose you want to draw segment [AB].
(more or less the technique used in ShaderX5)
But do this only if you can't use MSAA.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With