shithub: choc

Download patch

ref: d70c830b4d089e749ff5aa84a3d479be7911995a
parent: 67fae2be49cb9203de5b952ab8b17a37db800c15
author: Simon Howard <[email protected]>
date: Sat Apr 12 13:14:37 EDT 2014

video: Change default for screen_bpp to 0.

Some machines don't work well with 8-bit screen depths any more. It's
better to default to just using the machine's native color depth
instead. Change the default to 0 (for SDL_SetVideoMode this means "use
native color depth"), auto-adjust to native color depth on startup if
screen_bpp=0 (so that debug messages at least make sense) and document
for the config file value that a value of zero means "use native".

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -194,7 +194,7 @@
 
 // Color depth.
 
-int screen_bpp = 8;
+int screen_bpp = 0;
 
 // Automatically adjust video settings if the selected mode is 
 // not a valid video mode.
@@ -1461,6 +1461,19 @@
     SDL_PixelFormat format;
     const SDL_VideoInfo *info;
     int flags;
+
+    // If screen_bpp=0, we should use the current (default) pixel depth.
+    // Fetch it from SDL.
+
+    if (screen_bpp == 0)
+    {
+        info = SDL_GetVideoInfo();
+
+        if (info != NULL && info->vfmt != NULL)
+        {
+            screen_bpp = info->vfmt->BitsPerPixel;
+        }
+    }
 
     if (fullscreen)
     {
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -747,6 +747,8 @@
 
     //!
     // Color depth of the screen, in bits.
+    // If this is set to zero, the color depth will be automatically set
+    // on startup to the machine's default/native color depth.
     //
 
     CONFIG_VARIABLE_INT(screen_bpp),
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -106,7 +106,7 @@
 static int fullscreen = 1;
 static int screen_width = 320;
 static int screen_height = 200;
-static int screen_bpp = 8;
+static int screen_bpp = 0;
 static int startup_delay = 1000;
 static int usegamma = 0;