Antialiasing is a process whereby the jagged edges of a graphic can be smoothered to give a more pleasing and realistic appearance. This processes involves blending and so this needs to enabled for antialiasing to operate.

Anitaliasing is an intense in terms of processing and so there are several states that can individually enabled so those that do not need to be operational are not taking up unnecessary processor time. For example.


The following table are the three states

GL_POINT_SMOOTHrequired to make points larger that 2 pixels appear round
GL_LINE_SMOOTHantialiase all lines
GL_POLYGON_SMOOTHantialiase all polygon edges.

You can also give the graphics card a hint as to what quality of antialiasing to apply. The processor is not obliged to implement a hint. The method to offer this hint is

           GL11.glHint(target , hint)

The parameter target is the antialiasing state you wish to offer a hint. They are listed in the following table.

GL_POINT_SMOOTH_HINThint applies to points
GL_LINE_SMOOTH_HINThint applies to lines
GL_POLYGON_SMOOTH_HINThint applies to polygon edged
GL_FOG_HINTwhether fog is calculated per pixel ( GL_NICEST ) or per vertex (GL_FASTEST ). Fog to be covered later.
GL_PERSPECTIVE_CORRECTION_HINThint for the colour and texture interperlation while generating perspective

The value for the hint can be one of the following

GL_FASTESTtune antialiasing for speed
GL_NICESTtune antialiasing for quality
GL_DONT_CARElet the graphics card decide

Below is an interactive graphic demonstrating the effects of antialiasing. You can choose to apply antialiasing to a point, lines and polygons with a hint. The hint may or may not have an effect, depending on the graphics card. You can also choose to render with a double pass as outlined in the last section of Transparency. The double pass may improve the rendering of the lines and polygons.

For example to make good looking dots in your game 5 pixels across. The following code will draw a dot at location 1,2,-3.




antialiase text

We developed text in the section on Images. This text however did not have antialiase applied. To apply antialiase to the text we must first apply it to the String we draw onto the BufferedImage and then draw that image as usual onto our OpenGL Display. So we work with methods in the Graphics2D object. We need to place the Graphics2D object in antialiase mode when drawing text. The statement to do this is as follows.

     g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING , RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

Where g is the reference to the Graphics2D object as used in the section on Images.