Jarann Jarann - 15 days ago 8
C++ Question

Changing OpenGL anti aliasing after SDL window creation?

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.


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


So after some more testing I found that anti aliasing can be enabled and disabled through a glenable/disable function call. All you have to do is set the AA level compile time but use opengl to choose whether to use it. The only catch is that you can't change the level, but this solution works for my case

// When you want to enable it