summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2014-03-27 21:59:00 -0400
committerSimon Howard2014-03-27 21:59:00 -0400
commit16a0f227362f330bd9be0598f136eed05c811969 (patch)
tree2da5a3557aa33edde4d8e32ed41f607f1cc8d856 /src
parent5412004bfa32864c1034e81ee7b093d8887850f5 (diff)
downloadchocolate-doom-16a0f227362f330bd9be0598f136eed05c811969.tar.gz
chocolate-doom-16a0f227362f330bd9be0598f136eed05c811969.tar.bz2
chocolate-doom-16a0f227362f330bd9be0598f136eed05c811969.zip
video: Fix crash when running fullscreen with -2.
Remove special logic for setting a scale factor (2x, 3x, etc.) when running fullscreen instead of windowed. This fixes a crash due to the fact that I_GraphicsCheckCommandLine() is called before SDL's video subsystem is initialized. This makes -2 identical to -geometry 640x480, which is arguably a better (more easily comprehensible) behavior. Thanks to Fabian Greffrath for reporting the bug. This fixes #338.
Diffstat (limited to 'src')
-rw-r--r--src/i_video.c82
1 files changed, 11 insertions, 71 deletions
diff --git a/src/i_video.c b/src/i_video.c
index be40128f..a52f1a3b 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1546,83 +1546,23 @@ static void I_AutoAdjustSettings(void)
static void SetScaleFactor(int factor)
{
- if (fullscreen)
- {
- // In fullscreen, find a mode that will provide this scale factor
-
- SDL_Rect **modes;
- SDL_Rect *best_mode;
- screen_mode_t *scrmode;
- int best_num_pixels, num_pixels;
- int i;
-
- modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
-
- best_mode = NULL;
- best_num_pixels = INT_MAX;
-
- for (i=0; modes[i] != NULL; ++i)
- {
- // What screen_mode_t will this use?
-
- scrmode = I_FindScreenMode(modes[i]->w, modes[i]->h);
-
- if (scrmode == NULL)
- {
- continue;
- }
-
- // Only choose modes that fit the requested scale factor.
- //
- // Note that this allows 320x240 as valid for 1x scale, as
- // 240/200 is rounded down to 1 by integer division.
-
- if ((scrmode->width / SCREENWIDTH) != factor
- || (scrmode->height / SCREENHEIGHT) != factor)
- {
- continue;
- }
-
- // Is this a better mode than what we currently have?
-
- num_pixels = modes[i]->w * modes[i]->h;
+ int w, h;
- if (num_pixels < best_num_pixels)
- {
- best_num_pixels = num_pixels;
- best_mode = modes[i];
- }
- }
+ // Pick 320x200 or 320x240, depending on aspect ratio correct
- if (best_mode == NULL)
- {
- I_Error("No fullscreen graphics mode available to support "
- "%ix scale factor!", factor);
- }
-
- screen_width = best_mode->w;
- screen_height = best_mode->h;
+ if (aspect_ratio_correct)
+ {
+ w = SCREENWIDTH;
+ h = SCREENHEIGHT_4_3;
}
else
{
- int w, h;
-
- // Pick 320x200 or 320x240, depending on aspect ratio correct
-
- if (aspect_ratio_correct)
- {
- w = SCREENWIDTH;
- h = SCREENHEIGHT_4_3;
- }
- else
- {
- w = SCREENWIDTH;
- h = SCREENHEIGHT;
- }
-
- screen_width = w * factor;
- screen_height = h * factor;
+ w = SCREENWIDTH;
+ h = SCREENHEIGHT;
}
+
+ screen_width = w * factor;
+ screen_height = h * factor;
}
void I_GraphicsCheckCommandLine(void)