Tuesday, February 23, 2010

A Better Line

I was a bit hesitant to update with all the little things I've been doing but after chatting with a buddy of mine it's apparent that all those little things add up. I guess this will give me a steady supply of things to post here which is how I think I prefer it anyway.

On the graphics front, I found out that OpenGL actually supports anti-aliased lines as well as lines with thickness. This is quite a godsend as writing those routines is a bit tedious. Also, though I haven't tested it, I'm sure having the hardware render them is much faster than writing a software version anyway. I'm also pleased that I can easily do translucency with these lines as well.

 
After some research and more playing around I also discovered that I can write straight C functions alongside my Objective-C code. Now, I don't have to hack my preferred syntax for my drawing primitives using macros like I was doing previously. The star above was generated using such a routine. The results, though, demonstrate a problem with GLs thick lines in that as far as I know there's no way to generate end caps at the end points of the lines, making them rounded or beveled. Everything I've found indicates that I'll have to write this functionality myself if I want it.
One major benefit to having the anti-aliased lines available in GL is that I can use them to generate anti-aliased circles using a technique similar to the brute force method I used previously. Not only that, but the actual results are significantly better, displaying few visible artifacts.



No comments:

Post a Comment