diff --git a/engine/platform/sdl/vid_sdl.c b/engine/platform/sdl/vid_sdl.c index 06543e71..99cf6f3a 100644 --- a/engine/platform/sdl/vid_sdl.c +++ b/engine/platform/sdl/vid_sdl.c @@ -548,23 +548,29 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) xpos = ypos = 0; } - host.hWnd = SDL_CreateWindow( wndname, xpos, ypos, width, height, wndFlags ); - - if( !host.hWnd ) + while( glw_state.safe >= SAFE_NO && glw_state.safe < SAFE_LAST ) { - Con_Reportf( S_ERROR "VID_CreateWindow: couldn't create '%s': %s\n", wndname, SDL_GetError()); + host.hWnd = SDL_CreateWindow( wndname, xpos, ypos, width, height, wndFlags ); - // skip some attribs in hope that context creating will not fail - if( glw_state.safe >= SAFE_NO ) - { - if( !gl_wgl_msaa_samples->value && glw_state.safe + 1 == SAFE_NOMSAA ) - glw_state.safe += 2; // no need to skip msaa, if we already disabled it - else glw_state.safe++; - GL_SetupAttributes( ); // re-choose attributes + // we have window, exit loop + if( host.hWnd ) + break; - // try again - return VID_CreateWindow( width, height, fullscreen ); - } + Con_Reportf( S_ERROR "VID_CreateWindow: couldn't create '%s' with safegl level %d: %s\n", wndname, glw_state.safe, SDL_GetError()); + + glw_state.safe++; + + if( !gl_wgl_msaa_samples->value && glw_state.safe == SAFE_NOMSAA ) + glw_state.safe++; // no need to skip msaa, if we already disabled it + + GL_SetupAttributes(); // re-choose attributes + + // try again create window + } + + // window creation has failed... + if( glw_state.safe >= SAFE_LAST ) + { return false; } diff --git a/engine/ref_api.h b/engine/ref_api.h index fbe31b9d..932ff9e0 100644 --- a/engine/ref_api.h +++ b/engine/ref_api.h @@ -166,7 +166,8 @@ typedef enum SAFE_NOALPHA, // don't set alpha bits SAFE_NODEPTH, // don't set depth bits SAFE_NOCOLOR, // don't set color bits - SAFE_DONTCARE // ignore everything, let SDL/EGL decide + SAFE_DONTCARE, // ignore everything, let SDL/EGL decide + SAFE_LAST, // must be last } ref_safegl_context_t; enum // OpenGL configuration attributes