PDA

View Full Version : antialiasing polygon edges



David Patte
05-15-2010, 07:15 AM
Hi

I am writing a small app using opengl. But I have run into a problem with 'jaggies' on the edges of my polygons.

I have no problem antaliasing points and lines, but after searching this site, have found nothing here that seems to work in antialiasing the edges of the polygons when i try it in my code.

I've tried the technique of turning off depth testing, starting with a black, alpha-0 screen, and painting my polygons from back to front using glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE);
to no avail.

Any reasons why the antialias may not be working, and does anyone have some suggestions or tricks I might try to get this to work?

kowal
05-15-2010, 12:26 PM
Get opengl context with multisampling, in glx add this to requested attributes:
GLX_SAMPLE_BUFFERS, 1,
GLX_SAMPLES, 4

it should give You 4x antialiasing, wgl should have similar constants. (something like WGL_SAMPLE_BUFFERS and WGL_SAMPLES (not sure, i'm not using Windows anymore)).
If You are using glut afaik there is no way to create window with ms, but freeglut has support for multisampling.

You can force antialiasing in graphics driver control panel (at least in NV on linux)

Dark Photon
05-16-2010, 01:31 PM
Get opengl context with multisampling, in glx add this to requested attributes:
GLX_SAMPLE_BUFFERS, 1,
GLX_SAMPLES, 4

it should give You 4x antialiasing,
Also, don't forget to enable multisample rasterization: glEnable( GL_MULTISAMPLE ).


If You are using glut afaik there is no way to create window with ms, but freeglut has support for multisampling.
Right:
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);


You can force antialiasing in graphics driver control panel (at least in NV on linux)
Yeah, or just put this env var in the environment before you create your GL context (e.g. via putenv):

__GL_FSAA_MODE=5

To query the AA modes available for your card:

nvidia-settings --query=fsaa --verbose

See the NVidia driver README for details.