Revision as of 13:58, 24 July 2012 by Baggett.patrick (Talk | contribs)

Jump to: navigation, search

Multisampling is a method of achieving full-screen antialiasing, or FSAA for short. Unlike supersampling which can result in the same pixel being processed multiple times, multisampling runs the fragment program just once per pixel rasterized, however multiple depth/stencil values are computed.


Before GL_ARB_multisample extension, the edges of lines, polygons, and points could be selectively antialiased using using glEnable(GL_LINE_SMOOTH), glEnable(GL_POLYGON_SMOOTH), glEnable(GL_POINT_SMOOTH) respectively, combined with a blending function, such as glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). Such features were typically not implemented in hardware in early consumer graphics cards at the time, and were done in software resulting in poor performance. More expensive "workstation" graphics cards from HP, Sun, and SGI at the time did implement these features in hardware. Modern programs should not make use of these features.


The problem is that this part of OpenGL is platform specific. If you use freeGLUT, SDL or some other library, they hide this platform specific stuff. Here, we will talk about Windows and the platform specific API.

This is what you must do :

1. Start your program, open a dummy window for getting function pointers. You would use CreateWindowEx to create your window.

2. Make the window invisible ShowWindow(window.HWnd, SW_HIDE)

3. You can then SetPixelFormat, create the GL context, make the GL context current (wglMakeCurrent(hdc, glrc))

4. Now you can get the function pointers. If you are using GLEW

 GLenum err=glewInit();
    //Problem: glewInit failed, something is seriously wrong
    sprintf(pErrorMessage, "Error: %s", glewGetErrorString(err));
    return -1;

5. Check to see if the function pointer (wglGetExtensionsStringARB) is not NULL. If it is not NULL, call wglGetExtensionsStringARB(hdc) to get a list of WGL extensions supported.

6. WGL_ARB_pixel_format and WGL_ARB_multisample should be in the list. If they are, set some variable to TRUE and then make GL context non-current, kill the GL context, destroy the temporary window.

7. Now, create your real window. Make it visible.

8. Now you must check that variable that you had set. Is it FALSE or TRUE? If it is TRUE, then you can setup a FSAA pixelformat.

9. Since you have already called glewInit, you don't need to call it again. Use wglGetPixelFormatAttribivARB to collect information. Also keep in mind that a GL context is not needed for wgl functions to work such as wglGetPixelFormatAttribivARB.

10. When you find a pixelformat that you like, call the "traditional" SetPixelFormat. Make a GL context, make context current and now you are ready to render.

The most difficult part is choosing a suitable pixelformat. One that has the right color bits, depth bits, stencil bits, the right FSAA level.

You should also call glEnable(GL_MULTISAMPLE) but in reality this is useless since it is not possible to enable or disable FSAA once you have chosen a FSAA pixelformat.

In this entire document, we called it FSAA (Full Scene Anti-Aliasing) but it is also called MS (multisampling) since multiple samples are taken in various ways and the samples are blended together to give the resulting pixel. There is also another concept called supersampling and there are also nVidia specific GPU algorithms for sampling (see nVidia's documents on their developer website.

Here are the links to the extensions in question (Windows) :



These are for *nix systems :

- (GL_SGIS_multisample and GLX_SGIS_multisample are on the same page)

These are for all platforms :


These might interest you :





Setting up FSAA takes a few steps but it is worth it. Today's GPUs are very rapid and the user wants control over the quality of the game's graphics.
On Windows, the extension we are interested in are WGL_ARB_extensions_string which defines wglGetExtensionsStringARB, but the only way to check if this is available is to call wglGetExtensionsStringARB. So this is a chicken and egg situation. Just get the function pointer to wglGetExtensionsStringARB and use it to see if you have WGL_ARB_pixel_format and WGL_ARB_multisample.