When you draw a line in OpenGL, glLineWidth creates a fixed-size line, regardless how close the line is to you.
I wanted to draw a line that will appear bigger when it’s close. Now, I understand that if I use a rectangle to achieve this effect, it will look a bit pixelated once the polygon is far enough.
What I’ve previously done is to draw a normal GL_LINE up to the point where the line would get bigger than the pixel size, and then continue with a rectangle from that point. However, it’s not as fast as just chucking everything down to a vertex array or VBO, as it had to be recalculated every frame.
What other methods are available? Or am I stuck with this?
I like to use a gradated texture like this to draw lines:
This is really the alpha of my texture. So you have a fully opaque center fading to fully transparent at the edges. Then you can draw your line using a rectangle with points:
(x1,y1,0,0), (x2,y1,1,0), (x1,y2,0,1), (x2,y2,1,1)
where the last two entries in each tuple are u and v of the texture. It ends up looking very smooth. You can even string together lots of very small rectangles to make curvy lines.