Polygon Antialiasing

I need to be able to draw anti-aliased polygons, and have run across an article that describes the process as more than just enabling GL_POLYGON_SMOOTH along with alpha blending. In particular, depth sorting while enabling GL_DEPTH_TEST was mentioned. Is that accurate. I haven’t been able to get it to work with or without depth testing. Any help on this would be much appreciated…


This one?

You have destination alpha?

HLZ, thanks for the reply. Yes, that was the one I was referring to. I had depth testing backwards, but other than that, I’m still not seeing it work. I do have destination alpha
set with ChoosePixelFormat() (I’m in Win32).
Here’s the code. As you can see, I’ve
tried various blending functions with
the result that if I do what is suggested in
the article, nothing draws. If I use GL_SRC_ALPHA
and GL_ONE_MINUS_SRC_ALPHA for transparency, it
draws OK, but I don’t get any antialiasing:

 glEnable( GL_BLEND );
 glEnable( GL_ALPHA_TEST );

 glDisable( GL_DEPTH_TEST );


 glAlphaFunc( GL_GREATER, 0.25 );

 // nothing draws with this one:
 // no antialiasing results with this one:


 err = glGetError();

 glPolygonOffset( 0.0, .15 );

… drawPolys();

To get proper polygon AA (with blending-coverage), you have to draw on a black transparent background, with the glBlendFunc( GL_SRC_ALPHA_SATURATE, GL_ONE )setting. The other blend setting will result in visible edges between the triangles that make up the polygon (that’s why it needs the saturation). Sorting of the polygons is front-to-back and in the end draw a quad that covers the remaining black background with your desired colour.
BTW, if your card / driver doesn’t support this kind of polygon AA, my lines above won’t help you…