0
\$\begingroup\$

I am trying to get the Antialiasing (multisampling) in OpenGL with SDL to work(as shown here), but the result doesn't change and I still get jaggy edges.

Before rendering I call the following functions

glEnable(GL_MULTISAMPLE);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST );
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST );
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH); 

As I've been looking for a solution I added more functions to my SDL setup but nothing helped.

SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);


SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
        
SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" );
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); 

Window and Context are created via

window = SDL_CreateWindow(Window_title.str().c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags);
SDL_GLContext glContext = SDL_GL_CreateContext(window);

Any Ideas what I could do to get around this? Should I try a different approach for anti-aliasing?

Have I missed something about Multisampling / anti-aliasing, like there's an extra fragment shader needed or so?

Image from my Game showing the aliased edges

\$\endgroup\$
4
  • \$\begingroup\$ At best, multi-sampling will help only at the polygon edges. It won't do anything for the aliasing of individual texels in your nearest-neighbour filtered texture. So you'll want a different solution there, at minimum. \$\endgroup\$ Commented Apr 3, 2022 at 17:43
  • \$\begingroup\$ but I thought MSAA would at least smooth out the edges of the cubes... \$\endgroup\$ Commented Apr 3, 2022 at 18:12
  • \$\begingroup\$ @DMGregory♦ do you have any recommendations what technique I could use to get rid of the aliasing of the texels inside the texture? \$\endgroup\$ Commented Apr 3, 2022 at 18:33
  • \$\begingroup\$ This recent question links to a couple of such methods. \$\endgroup\$ Commented Apr 3, 2022 at 20:19

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.