diff options
author | Simon Howard | 2010-11-29 20:18:10 +0000 |
---|---|---|
committer | Simon Howard | 2010-11-29 20:18:10 +0000 |
commit | 6307e5e2519c165ea0c9496849e8013cd92315e1 (patch) | |
tree | 20369ad01285630c7646f03799fee8eee3d61823 /setup | |
parent | d417ce23d62443acea51fd11d24e83dd83d46188 (diff) | |
download | chocolate-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 'setup')
-rw-r--r-- | setup/display.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/setup/display.c b/setup/display.c index b20b6667..42a1dced 100644 --- a/setup/display.c +++ b/setup/display.c @@ -243,7 +243,7 @@ static int GetSupportedBPPIndex(char *description) return i; } } - + // Shouldn't happen; fall back to the first in the list. return 0; @@ -251,7 +251,7 @@ static int GetSupportedBPPIndex(char *description) // Set selected_bpp to match screen_bpp. -static void SetSelectedBPP(void) +static int TrySetSelectedBPP(void) { unsigned int num_depths = sizeof(pixel_depths) / sizeof(*pixel_depths); unsigned int i; @@ -264,16 +264,41 @@ static void SetSelectedBPP(void) if (pixel_depths[i].bpp == screen_bpp) { selected_bpp = GetSupportedBPPIndex(pixel_depths[i].description); - return; + return 1; } } - // screen_bpp does not match anything in pixel_depths. Set selected_bpp - // to something that is supported, and reset screen_bpp to something - // sensible while we're at it. + return 0; +} - selected_bpp = 0; - screen_bpp = GetSelectedBPP(); +static void SetSelectedBPP(void) +{ + const SDL_VideoInfo *info; + + if (TrySetSelectedBPP()) + { + return; + } + + // screen_bpp does not match any supported pixel depth. Query SDL + // to find out what it recommends using. + + info = SDL_GetVideoInfo(); + + if (info != NULL && info->vfmt != NULL) + { + screen_bpp = info->vfmt->BitsPerPixel; + } + + // Try again. + + if (!TrySetSelectedBPP()) + { + // Give up and just use the first in the list. + + selected_bpp = 0; + screen_bpp = GetSelectedBPP(); + } } static void ModeSelected(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(mode)) |