Saturday, January 30, 2010

Antialiasing (multisampling) OpenGL with SDL

Very straight forward. After the "SDL_Init" call, simply call:
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
before the call to "SDL_SetVideoMode".

You will need to call
glEnable(GL_MULTISAMPLE);
as well.

The smooth hint calls might help you too:
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST );
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST );
 
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
All done, you should see smoothed edges (as in the picture above, left is antialiased, right has jaggy edges)

No comments: