Anti-Aliased Filled Polygon Algo

Started by
2 comments, last by superpig 19 years, 3 months ago
Hi all, i'm trying to implement a nice text effect in my painting app and i'm having difficulties getting a decent fast rendering done. If you don't know what i'm trying to achieve, look at DDTitle. It works with the installed fonts and renders the fonts pretty fast, even with all the effects done. My idea is this: I'm retrieving the glyphs/outlines via the windows GDI functions (BeginPath etc.), transform them and use the line lists to render filled polygons. I can draw simple aa-ed lines easily but what i'd really like to do would be filled polygons, but aa-ed on the border. Trouble arises, when letters have holes inside. I'm thinking that i'll need to tesselate (split up in triangles) the polygon. I don't want to use third party libs (like freetype) since i want to learn by doing that. My question in that case, any idea on how to implement that in a fast enough way? Any hints on what approach to take? Thanks in advance, Endurion

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Advertisement
Perhaps you could do it by capturing the background first, drawing the character with holes filled in (and edges antialiased), and then drawing the hole over the top (again, with edges antialiased) using the captured background as a source?

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Might work, i'd like to preserve the background though without capturing.

In addition to your suggestion, i could render the full area in a gray/alpha-image (8 bit ought to be enough) followed by the holes. Then use this alpha image to blend onto the background.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Indeed. Personally I like that kind of thing because it allows you to use the result as a mask much more easily (allowing, for example, patterned/textured text).

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement