ref: af271211eb9c173d5247a0ad4b25971f1b4d350f
parent: 4fa746dac55ae0cce8f52caf1bedb7616925e04c
author: Simon Howard <[email protected]>
date: Tue May 31 18:41:54 EDT 2016
video: Set minimum window size for SDL window. When resizing, scaling breaks down at really small sizes. It's best to enforce a limit so that we don't scale down beyond the base size.
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -264,21 +264,28 @@
}
-// Adjust screen_width / screen_height variables to be an an aspect
-// ratio consistent with the aspect_ratio_correct variable.
-static void AdjustWindowSize(void)
+// Returns base screen height - either SCREENHEIGHT_4_3 or SCREENHEIGHT,
+// dependent on aspect_ratio_correct value.
+static int EffectiveScreenHeight(void)
{
- int h;
-
if (aspect_ratio_correct)
{
- h = SCREENHEIGHT_4_3;
+ return SCREENHEIGHT_4_3;
}
else
{
- h = SCREENHEIGHT;
+ return SCREENHEIGHT;
}
+}
+// Adjust screen_width / screen_height variables to be an an aspect
+// ratio consistent with the aspect_ratio_correct variable.
+static void AdjustWindowSize(void)
+{
+ int h;
+
+ h = EffectiveScreenHeight();
+
if (screen_width * h <= screen_height * SCREENWIDTH)
{
// The +1 here stops us from repeatedly shrinking the screen size
@@ -505,9 +512,7 @@
static void CreateUpscaledTexture(void)
{
- const int actualheight = aspect_ratio_correct ?
- SCREENHEIGHT_4_3 :
- SCREENHEIGHT;
+ const int actualheight = EffectiveScreenHeight();
int w, h;
int h_upscale, w_upscale;
static int h_upscale_old, w_upscale_old;
@@ -780,23 +785,10 @@
static void SetScaleFactor(int factor)
{
- 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;
+ screen_width = factor * SCREENWIDTH;
+ screen_height = factor * EffectiveScreenHeight();
}
void I_GraphicsCheckCommandLine(void)
@@ -1063,6 +1055,8 @@
w, h, SDL_GetError());
}
+ SDL_SetWindowMinimumSize(screen, SCREENWIDTH, EffectiveScreenHeight());
+
// If we are running fullscreen, the whole screen is our "window".
if (fullscreen)
@@ -1096,7 +1090,7 @@
SDL_RenderSetLogicalSize(renderer,
SCREENWIDTH,
- aspect_ratio_correct ? SCREENHEIGHT_4_3 : SCREENHEIGHT);
+ EffectiveScreenHeight());
I_InitWindowTitle();
I_InitWindowIcon();