]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
Don't allow a higher depth than the desktop when using a windowed mode on Win32....
[xonotic/darkplaces.git] / vid_wgl.c
index e23b1bc7ca84849d3d06363a4ea7b4bbfcc2f2ed..fed809b0213e54ab80464d69ffe83b00f98a6fc8 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "resource.h"
 #include <commctrl.h>
 
+// Tell startup code that we have a client
 int cl_available = true;
 
 int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
@@ -750,6 +751,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
        HGLRC baseRC;
        int CenterX, CenterY;
        const char *gldrivername;
+       int depth;
 
        if (vid_initialized)
                Sys_Error("VID_InitMode called when video is already initialised\n");
@@ -801,6 +803,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
        {
                hdc = GetDC (NULL);
                i = GetDeviceCaps(hdc, RASTERCAPS);
+               depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
                ReleaseDC (NULL, hdc);
                if (i & RC_PALETTE)
                {
@@ -808,6 +811,12 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
                        Con_Printf ("Can't run in non-RGB mode\n");
                        return false;
                }
+               if (bpp > depth)
+               {
+                       VID_Shutdown();
+                       Con_Printf ("A higher desktop depth is required to run this video mode\n");
+                       return false;
+               }
 
                WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
                ExWindowStyle = 0;