]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
improved handling of video mode failures
[xonotic/darkplaces.git] / vid_shared.c
index de2f788dcd9ffaad5e095a4cd4df0c4e80bd7c53..b0568601358366cf59067fdda4add97edb49e5e0 100644 (file)
@@ -1,9 +1,6 @@
 
 #include "quakedef.h"
 
-// Tell startup code that we have a client
-int cl_available = true;
-
 // global video state
 viddef_t vid;
 
@@ -244,7 +241,7 @@ int GL_CheckExtension(const char *name, const dllfunction_t *funcs, const char *
        for (func = funcs;func && func->name;func++)
                *func->funcvariable = NULL;
 
-       if (disableparm && COM_CheckParm(disableparm))
+       if (disableparm && (COM_CheckParm(disableparm) || COM_CheckParm("-safe")))
        {
                Con_DPrintf("disabled by commandline\n");
                return false;
@@ -765,7 +762,6 @@ int current_vid_fullscreen;
 int current_vid_width;
 int current_vid_height;
 int current_vid_bitsperpixel;
-extern int VID_InitMode (int fullscreen, int width, int height, int bpp);
 int VID_Mode(int fullscreen, int width, int height, int bpp)
 {
        Con_Printf("Video: %s %dx%dx%d\n", fullscreen ? "fullscreen" : "window", width, height, bpp);
@@ -822,14 +818,14 @@ void VID_Restart_f(void)
 
 void VID_Open(void)
 {
-       int i, width, height;
+       int i, width, height, success;
        if (vid_commandlinecheck)
        {
                // interpret command-line parameters
                vid_commandlinecheck = false;
-               if ((i = COM_CheckParm("-window")) != 0)
+               if (COM_CheckParm("-window") || COM_CheckParm("-safe"))
                        Cvar_SetValueQuick(&vid_fullscreen, false);
-               if ((i = COM_CheckParm("-fullscreen")) != 0)
+               if (COM_CheckParm("-fullscreen"))
                        Cvar_SetValueQuick(&vid_fullscreen, true);
                width = 0;
                height = 0;
@@ -850,17 +846,18 @@ void VID_Open(void)
        }
 
        Con_DPrintf("Starting video system\n");
-       if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer))
+       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer);
+       if (!success)
        {
                Con_Printf("Desired video mode fail, trying fallbacks...\n");
-               if (vid_fullscreen.integer)
-               {
-                       if (!VID_Mode(true, 640, 480, 16))
-                               if (!VID_Mode(false, 640, 480, 16))
-                                       Sys_Error("Video modes failed\n");
-               }
-               else
-                       Sys_Error("Windowed video failed\n");
+               if (!success && vid_bitsperpixel.integer > 16)
+                       success = VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, 16);
+               if (!success && (vid_width.integer > 640 || vid_height.integer > 480))
+                       success = VID_Mode(vid_fullscreen.integer, 640, 480, 16);
+               if (!success && vid_fullscreen.integer)
+                       success = VID_Mode(false, 640, 480, 16);
+               if (!success)
+                       Sys_Error("Video modes failed\n");
        }
        VID_OpenSystems();
 }