I'm learning OpenGL and something I am stuck with is AA. Specially when I want to turn it on and off at runtime. I know that I can set the samplecount when I create a FBO and blit it over to the final window. When I want to change the mode I switch the FBO and everything is fine. The question I am completely stuck with is, how do I change the mode and also important, how do I query the modes that the card supports. With mode I mean CSAA,MSAA,.. .I can't find a lot. At least I know that it is vendor specific. Hope anyone can point me in the right direction. Thanks
2 Answers
Multisampling is a property of the framebuffer. You enable multisampling by rendering to a multisampled framebuffer while GL_MULTISAMPLING
is enabled. If GL_MULTISAMPLING
is not enabled when you render to a multisample framebuffer, the pixels covered by that rendering operation replicate their data across all covered samples.
To make a framebuffer object a multisampled framebuffer, you attach multisampled images to it. They will all need to use the same sample count, and all images in the framebuffer must be multisample.
To make the default framebuffer multisampled, you must create your context with multiple samples. This requires the use of the WGL/GLX_ARB_multisample extension, as appropriate to your platform.
Nowadays, the general pattern is to leave the default framebuffer non-multisampled and create your own multisample FBO images. Then, you blit from your multisample FBO to the default framebuffer's back buffer to display the multisampled data.
CSAA is an NVIDIA thing, with an extension to govern its use.
FXAA is not a piece of hardware; it's an algorithm. Some drivers have control panel settings that back-door it in. That's generally a bad idea, since they can't tell when you're rendering the UI (something that shouldn't use the FXAA algorithm). So it's generally up to you to implement it.
-
2\$\begingroup\$ I'd add to the last point, that the FXAA algorithm is available for download for both DirectX and OpenGL from the Nvidia developer who made it. \$\endgroup\$– akaltarCommented Dec 3, 2015 at 17:19
FXAA doesn't come with OpenGL implementations, you have to find and use a shader that implements it.
CSAA can be used on NVIDIA GPUs using GL_NV_framebuffer_multisample_coverage
.
-
\$\begingroup\$ OP also asked about MSAA, which must set when conxtext is created. There are special functions to enable MSAA in libraries (like SDL or GLFW) that can create contexts. \$\endgroup\$ Commented Dec 3, 2015 at 12:30