|OpenGL Multisample Anti-Aliasing Demo.
This Windows demo shows you how to make use of OpenGL's multisample anti-aliasing (MSAA) capabilities to anti-alias primitives.
This demo contains a scene with two primitives: a colored triangle, and a textured quad. The triangle illustrates how MSAA can effectively reduce the jagged edges of polygons. The quad is textured with a typical wire fence bitmap. The wire fence texture contains an alpha mask embedded in the texture's alpha channel. When drawn using alpha testing alone without MSAA the hard edges of the wire fence's alpha mask are visible. We use a feature of OpenGL's multisampling extension called alpha to coverage to include the fragment's alpha component when performing anti-aliasing. The overall effect reduces the appearance of the hard edges of the fence's alpha mask.
This demo requires the following OpenGL extensions:
This demo makes use of these optional OpenGL extensions when available:
This demo requires the Visual C++ 2010 Library Runtimes. Download instructions can be found here.
Download executable, source, and Visual C++ 2010 solution files.
10 July 2010.
Added missing .vcxproj.filters file to the project.
13 June 2010.
Updated solution to Microsoft Visual Studio 2010.
15 June 2008.
main.cpp: Updated all references to ChooseBestMultiSampleAntiAliasingPixelFormat() to ChooseBestAntiAliasingPixelFormat(). Updated all references to ChooseMultiSampleAntiAliasingPixelFormat() to ChooseAntiAliasingPixelFormat(). Updated DrawText() to call GetAntiAliasingPixelFormatString() to fetch the active anti-aliasing format.
WGL_ARB_multisample.h: Added support for coverage sample anti-aliasing (CSAA) for NVIDIA GeForce 8 series and higher cards. Replaced ChooseBestMultiSampleAntiAliasingPixelFormat() with ChooseBestAntiAliasingPixelFormat(). Replaced ChooseMultiSampleAntiAliasingPixelFormat() with ChooseAntiAliasingPixelFormat(). Added GetAntiAliasingPixelFormatString().
WGL_ARB_multisample.cpp: ChooseBestAntiAliasingPixelFormat() and ChooseAntiAliasingPixelFormat() will select a coverage sample anti-aliasing (CSAA) pixel format if the OpenGL hardware supports it. GetAntiAliasingPixelFormatString() will return a string containing the most recently selected anti-aliasing pixel format. The returned string will indicated whether a CSAA or MSAA pixel format has been selected.
2 February 2008.
Updated solution to Microsoft Visual Studio 2008.
22 December 2007.
WGL_ARB_multisample.h: Added missing extern "C" declaration.
gl_font.h: Fixed incorrect include statement.. Updated code sample in the class description.
gl_font.cpp: Modified the begin() method to reduce the amount of state saving prior to beginning font rendering. Modified the end() method to reduce the amount of state restore after font rendering.
20 December 2007.
main.cpp: Major rewrite. Function prototypes added. Functions sorted by name. Added font support. This replaces the previous text output to the window caption. Added support for Windows Vista.
WGL_ARB_multisample.h: The function pointers to the entry point functions have been replaced with proper functions. This is more IntelliSense friendly.
WGL_ARB_multisample.cpp: InitExtentions() function removed. Wrapper functions added for each extension entry point. These new wrapper functions contain function pointers to the entry points and are initialized on first use.