From 8a5dde537229c23fd07203c71d59a66d60cc43e6 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 6 Dec 2011 13:50:06 +0000 Subject: [PATCH] Try to recover to gl_mode 4 if the choosen mode could not be set. This is just another hack to help stupid (mostly Ubuntu) users and imo completly unnecessary. --- src/sdl/refresh.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/sdl/refresh.c b/src/sdl/refresh.c index a3ad9d1d..28297fd9 100644 --- a/src/sdl/refresh.c +++ b/src/sdl/refresh.c @@ -142,6 +142,7 @@ UpdateHardwareGamma(void) */ static qboolean GLimp_InitGraphics( qboolean fullscreen ) { + int counter = 0; int flags; int stencil_bits; @@ -192,10 +193,32 @@ static qboolean GLimp_InitGraphics( qboolean fullscreen ) /* Set the icon */ SetSDLIcon(); - if ((surface = SDL_SetVideoMode(vid.width, vid.height, 0, flags)) == NULL) + while (1) { - Sys_Error("(SDLGL) SDL SetVideoMode failed: %s\n", SDL_GetError()); - return false; + if ((surface = SDL_SetVideoMode(vid.width, vid.height, 0, flags)) == NULL) + { + if (counter == 1) + { + Sys_Error(PRINT_ALL, "Failed to revert to gl_mode 4. Exiting...\n"); + return false; + } + + ri.Con_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n", SDL_GetError()); + ri.Con_Printf(PRINT_ALL, "Reverting to gl_mode 4 (640x480) and windowed mode.\n"); + + /* Try to recover */ + ri.Cvar_SetValue("gl_mode", 4); + ri.Cvar_SetValue("vid_fullscreen", 0); + vid.width = 640; + vid.height = 480; + + counter++; + continue; + } + else + { + break; + } } /* Initialize the stencil buffer */