summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2010-11-29 20:18:10 +0000
committerSimon Howard2010-11-29 20:18:10 +0000
commit6307e5e2519c165ea0c9496849e8013cd92315e1 (patch)
tree20369ad01285630c7646f03799fee8eee3d61823 /src
parentd417ce23d62443acea51fd11d24e83dd83d46188 (diff)
downloadchocolate-doom-6307e5e2519c165ea0c9496849e8013cd92315e1.tar.gz
chocolate-doom-6307e5e2519c165ea0c9496849e8013cd92315e1.tar.bz2
chocolate-doom-6307e5e2519c165ea0c9496849e8013cd92315e1.zip
Auto-adjust the screen color depth if the configured color depth is not
supported by the hardware. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2174
Diffstat (limited to 'src')
-rw-r--r--src/i_video.c55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/i_video.c b/src/i_video.c
index 62c74b73..488c08a0 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1207,15 +1207,61 @@ static void AutoAdjustWindowed(void)
}
}
+// Auto-adjust to a valid color depth.
+
+static void AutoAdjustColorDepth(void)
+{
+ SDL_Rect **modes;
+ SDL_PixelFormat format;
+ const SDL_VideoInfo *info;
+ int flags;
+
+ if (fullscreen)
+ {
+ flags = SDL_FULLSCREEN;
+ }
+ else
+ {
+ flags = 0;
+ }
+
+ format.BitsPerPixel = screen_bpp;
+ format.BytesPerPixel = (screen_bpp + 7) / 8;
+
+ // Are any screen modes supported at the configured color depth?
+
+ modes = SDL_ListModes(&format, flags);
+
+ // If not, we must autoadjust to something sensible.
+
+ if (modes == NULL)
+ {
+ printf("I_InitGraphics: %ibpp color depth not supported.\n",
+ screen_bpp);
+
+ info = SDL_GetVideoInfo();
+
+ if (info != NULL && info->vfmt != NULL)
+ {
+ screen_bpp = info->vfmt->BitsPerPixel;
+ }
+ }
+}
+
// If the video mode set in the configuration file is not available,
// try to choose a different mode.
static void I_AutoAdjustSettings(void)
{
- int old_screen_w, old_screen_h;
+ int old_screen_w, old_screen_h, old_screen_bpp;
old_screen_w = screen_width;
old_screen_h = screen_height;
+ old_screen_bpp = screen_bpp;
+
+ // Possibly adjust color depth.
+
+ AutoAdjustColorDepth();
// If we are running fullscreen, try to autoadjust to a valid fullscreen
// mode. If this is impossible, switch to windowed.
@@ -1234,10 +1280,11 @@ static void I_AutoAdjustSettings(void)
// Have the settings changed? Show a message.
- if (screen_width != old_screen_w || screen_height != old_screen_h)
+ if (screen_width != old_screen_w || screen_height != old_screen_h
+ || screen_bpp != old_screen_bpp)
{
- printf("I_InitGraphics: Auto-adjusted to %ix%i.\n",
- screen_width, screen_height);
+ printf("I_InitGraphics: Auto-adjusted to %ix%ix%ibpp.\n",
+ screen_width, screen_height, screen_bpp);
printf("NOTE: Your video settings have been adjusted. "
"To disable this behavior,\n"