add aspect_ratio_mode_t, fix starting with "high" with non-native aspect ratio

This commit is contained in:
Roman Fomin 2023-12-17 15:37:28 +07:00
parent 8d2c454670
commit ba70ba460c
3 changed files with 33 additions and 38 deletions

View File

@ -54,7 +54,7 @@ boolean uncapped, default_uncapped; // [FG] uncapped rendering frame rate
int fpslimit; // when uncapped, limit framerate to this value int fpslimit; // when uncapped, limit framerate to this value
boolean fullscreen; boolean fullscreen;
boolean exclusive_fullscreen; boolean exclusive_fullscreen;
int widescreen; // widescreen mode aspect_ratio_mode_t widescreen, default_widescreen; // widescreen mode
boolean vga_porch_flash; // emulate VGA "porch" behaviour boolean vga_porch_flash; // emulate VGA "porch" behaviour
boolean smooth_scaling; boolean smooth_scaling;
@ -975,40 +975,35 @@ static void ResetResolution(int height)
{ {
int w, h; int w, h;
if (height > native_height_adjusted)
{
return;
}
actualheight = use_aspect ? (int)(height * 1.2) : height; actualheight = use_aspect ? (int)(height * 1.2) : height;
video.height = height; video.height = height;
if (widescreen) switch (widescreen)
{ {
switch(widescreen) case RATIO_ORIG:
{ w = 4;
case RATIO_16_10: h = 3;
w = 16; break;
h = 10; case RATIO_MATCH_SCREEN:
break; w = native_width;
case RATIO_16_9: h = native_height;
w = 16; break;
h = 9; case RATIO_16_10:
break; w = 16;
case RATIO_21_9: h = 10;
w = 21; break;
h = 9; case RATIO_16_9:
break; w = 16;
default: h = 9;
w = native_width; break;
h = native_height; case RATIO_21_9:
break; w = 21;
} h = 9;
} break;
else default:
{ w = 16;
w = 4; h = 9;
h = 3; break;
} }
double aspect_ratio = (double)w / (double)h; double aspect_ratio = (double)w / (double)h;
@ -1432,16 +1427,15 @@ static void CreateSurfaces(void)
SDL_TEXTUREACCESS_STREAMING, SDL_TEXTUREACCESS_STREAMING,
w, h); w, h);
int oldwidescreen = widescreen;
widescreen = RATIO_MATCH_SCREEN; widescreen = RATIO_MATCH_SCREEN;
ResetResolution(h); ResetResolution(h);
R_InitAnyRes(); R_InitAnyRes();
ST_InitRes(); ST_InitRes();
widescreen = oldwidescreen; widescreen = default_widescreen;
if (resolution_mode != RES_DRS) if (resolution_mode != RES_DRS || widescreen != RATIO_MATCH_SCREEN)
{ {
ResetResolution(CurrentResolutionMode()); ResetResolution(CurrentResolutionMode());
} }
@ -1484,6 +1478,7 @@ static void I_ReinitGraphicsMode(void)
void I_ResetScreen(void) void I_ResetScreen(void)
{ {
resolution_mode = default_resolution_mode; resolution_mode = default_resolution_mode;
widescreen = default_widescreen;
ResetResolution(CurrentResolutionMode()); ResetResolution(CurrentResolutionMode());
ResetLogicalSize(); ResetLogicalSize();

View File

@ -24,7 +24,7 @@
#include "doomtype.h" #include "doomtype.h"
enum typedef enum
{ {
RATIO_ORIG, RATIO_ORIG,
RATIO_MATCH_SCREEN, RATIO_MATCH_SCREEN,
@ -32,7 +32,7 @@ enum
RATIO_16_9, RATIO_16_9,
RATIO_21_9, RATIO_21_9,
NUM_RATIOS NUM_RATIOS
}; } aspect_ratio_mode_t;
typedef enum typedef enum
{ {
@ -76,7 +76,7 @@ extern boolean exclusive_fullscreen;
extern int fpslimit; // when uncapped, limit framerate to this value extern int fpslimit; // when uncapped, limit framerate to this value
extern int fps; extern int fps;
extern boolean vga_porch_flash; // emulate VGA "porch" behaviour extern boolean vga_porch_flash; // emulate VGA "porch" behaviour
extern int widescreen; // widescreen mode extern aspect_ratio_mode_t widescreen, default_widescreen; // widescreen mode
extern int video_display; // display index extern int video_display; // display index
extern boolean screenvisible; extern boolean screenvisible;
extern boolean window_focused; extern boolean window_focused;

View File

@ -186,7 +186,7 @@ default_t defaults[] = {
// widescreen mode // widescreen mode
{ {
"widescreen", "widescreen",
(config_t *) &widescreen, NULL, (config_t *) &default_widescreen, NULL,
{RATIO_MATCH_SCREEN}, {RATIO_ORIG, NUM_RATIOS-1}, number, ss_none, wad_no, {RATIO_MATCH_SCREEN}, {RATIO_ORIG, NUM_RATIOS-1}, number, ss_none, wad_no,
"widescreen mode (0 = disable, 1 = match screen, 2 = 16:10, 3 = 16:9, 4 = 21:9)" "widescreen mode (0 = disable, 1 = match screen, 2 = 16:10, 3 = 16:9, 4 = 21:9)"
}, },