SDL_CreateWindow fails on Linux when using MSAA GLES2.0

I’m having a problem using multisampling with SDL2 on Linux. The SDL error message I’m receiving is “Could not find matching GLX visual”. The code I am using before create window is as follows:

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); // or 2, 8, 16, none work

I’m running Ubuntu 16.04 64 bit with the proprietary 381.09 nvidia drivers. My graphics card is a GeForce 750 Ti.

I’ve had this problem in the past on another machine with a previous build of SDL2 and different hardware. What’s the deal?

Can you post xdpyinfo and glxinfo for this system?

Have you tried it using straight GL instead of ES?

In previous attempts with different hardware create window failed with gl 4 core profile. Here is some output.

xdpyinfo:

glxinfo:

Interesting how all the multisample visuals and configs are non-conformant.

Try to match the attributes more closely:

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_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); // or 0 if you don't need it.

Do not set SDL_GL_ACCELERATED_VISUAL to anything above -1 or, I think, it will not consider the non-conformant ones.

It looks like it uses the GLX route. Perhaps you have more success with EGL. Set the SDL_OPENGL_ES_DRIVER environment variable to 1 and check if anything changes. I’m not that familiar with the X11 code in SDL, this may not do anything.

1 Like

@ChliHug That did it. I removed SDL_GL_ACCELERATED_VISUAL and it works now. Thanks!