Command line parameters -width and -height now accept custom resolutions

This commit is contained in:
Hannu Hanhi authored and Ashnal committed 2020-05-15 14:22:11 -04:00
1 parent f3c2e5d045
commit 866fd73a4f
1 file changed
+21
+21
View File
@@ -166,6 +166,10 @@ static INT32 windowedModes[MAXWINMODES][2] =
{ 320, 200}, // 1.60,1.00
};
#define CUSTOMMODENUM 9999
static INT32 custom_width = 0;
static INT32 custom_height = 0;
static void Impl_VideoSetupSDLBuffer(void);
static void Impl_VideoSetupBuffer(void);
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
@@ -1512,6 +1516,16 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h)
return i;
}
}
// did not find mode from list, make custom resolution if the values somewhat make sense
// opengl mode does not mind about max resolution defined in screen.h
// if not using opengl, check against the maximum as well
if ((w >= BASEVIDWIDTH && h >= BASEVIDHEIGHT) &&
(rendermode == render_opengl || (w <= MAXVIDWIDTH && h <= MAXVIDHEIGHT)))
{
custom_width = w;
custom_height = h;
return CUSTOMMODENUM;
}
return -1;
#if 0
INT32 matchMode = -1, i;
@@ -1625,6 +1639,13 @@ INT32 VID_SetMode(INT32 modeNum)
vid.height = windowedModes[modeNum][1];
vid.modenum = modeNum;
}
else if (modeNum == CUSTOMMODENUM && custom_width && custom_height)
{
// at this point these values are assumed to be okay
vid.width = custom_width;
vid.height = custom_height;
vid.modenum = modeNum;
}
else
{
// just set the desktop resolution as a fallback