Children are natural mimics who act like their parents despite every effort to teach them good manners. Concept 2.3 : Antialiasing Polygons =================================== Idea: ===== Antialiasinng the edges of filled polygons is similar to antialiasing points, and lines. When different polygons have over-lapping edges, we need to blend the color values appropriately. To antialias polygons in RGBA mode: o Use the alpha value to represent coverage values of polygon edges o Enable polygon antialiasing by passing GL_POLYGON_SMOOTH to glEnable(). This causes pixels on the edges of the polygons to be assigned fractional alpha values based on their coverage as though they were lines being antialiased. Remember : ========== When performing antialiasing, OpenGL calculates a coverage value for each fragment based on the fraction pixel square on the screen that it would cover. In RGBA mode, OpenGL multiplies the fragments coverage value by its alpha value. o Supply a value for GL_POLYGON_SMOOTH_HINT if desired. o Next we need to blend overlapping images properly. To do this, first turn off the depth buffer by calling glDepthMask() with GL_FALSE as the arguement. This way we have control over how overlapping pixels are drawn. o Set the blending factors to GL_SRC_ALPHA_ SATURATE for the source and GL_ONE for the destination. With this blending, the final color is the sum of the destination color and the scaled source color. o finally sort all the polygons in the scene so that they are ordered from front to back before drawing them. Example ======= The example to your left shows how to antialias filled polygon. Pressing the 't' key toggles the antialiasing on and off. Note: ===== For this technique to work correctly make sure to include GLUT_ALPHA as an option for the glutInitDisplayMode()