If SDL window fails, retry without MSAA (multisample antialiasing)
authorAndreas Eversberg <jolly@eversberg.eu>
Mon, 30 Apr 2018 10:07:03 +0000 (12:07 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Mon, 30 Apr 2018 10:07:03 +0000 (12:07 +0200)
src/libsdl/sdl.c

index 0b17c16..29344cd 100644 (file)
@@ -64,6 +64,7 @@ int init_sdl(const char *progname, int width, int height, int sound_samplerate,
        }
        sdl_initialized = 1;
 
+retry_without_multisampling:
        if (multisampling > 1) {
                SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
                SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
@@ -77,7 +78,16 @@ int init_sdl(const char *progname, int width, int height, int sound_samplerate,
        /* open window */
        gl_window = SDL_CreateWindow(progname, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
        if (!gl_window) {
-               print_error("Failed to open SDL window: %s (try without multisampling)\n", SDL_GetError());
+               if (multisampling) {
+                       print_info("Failed to open SDL window: %s (retrying without multisampling)\n", SDL_GetError());
+                       SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
+                       SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
+                       multisampling = 0;
+                       goto retry_without_multisampling;
+               }
+               print_error("Failed to open SDL window: %s\n", SDL_GetError());
+               SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
+               SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, multisampling);
                rc = EIO;
                goto error;
        }