🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Smooth Lines

Started by
2 comments, last by Andrew Russell 17 years, 7 months ago
Hey guys, I need help drawing smooth lines. I'm not talking about jaggies, I'm talking about the two end points of a wide line. If you set the line width to a large number the lines appear as rectangles. I'd like them to be smooth (ex. use the brush in mspaint). One possible way I thought of is to draw half circles at each edge- but I'm wondering if there are better ways to do it. Note: If you're curious I'm using lines to draw various 2D stuff. The lines are rather large, glLineWidth(20.0f). I have considered using triangles instead of lines since they're so big, but I'm not sure about the internal differences between the two, if someone could make a recommendation I would appreciate it. Thanks in advance!
Advertisement
Though there are a couple of ways of doing this, there are no real easy ways.
You could use a texture (with a dot on it) and draw a set of 3 quads instead of a line with the two outer quads are the top and bottom half of the texture and the central quad is a line though the middle (this is by the way how lightsabers are made).
You could draw a line as normal, and then draw circles at the ends.
Or as you said make the lines and end cap a poly object.

When it comes to lines and quads, there is no real difference between them since they are rendered the same way on the hardware, except for one.
Lines stay the same width regardless of the distance, polygons don't (but that can be fixed with some clever math or orthographic mode).
Thanks for your reply!

I can't use textures, the whole point of using lines is to not use textures.

I never noticed that lines stay at the same width- I guess I'll have to use quads instead. I'll just use a quad with a poly at each end.

Thanks a lot for your reply =D
(mod-bumped by request)

This topic is closed to new replies.

Advertisement