4
votes

I've ran into a problem where I want to be able to change anti aliasing while the window is open. SDL2 only allows for anti aliasing (sampling) to be set before the window is created and I was wondering if there's a way to no have to recreate the window every time I change the sample level.

Example:

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); // Before the window
SDL_Window* window = SDL_CreateWindow("title", 0, 0, 960, 540, SDL_WINDOW_OPENGL);
1

1 Answers

3
votes

If you want multisampling to be part of your window, then you have no choice but to recreate the window.

However, multisampling is a function of a render target. So if you want greater control over it, all you need to do is allocate a multisampled rendebuffer yourself, attach it to a framebuffer object, and then render to that (along with an appropriate depth/stencil buffer, depending on your particular needs). When you want to display the image, blit the multisampled renderbuffer to the window.