ui: Add option for a fixed 16:9 display ratio

This commit is contained in:
7oxicshadow 2021-07-31 22:38:45 +01:00 committed by mborgerson
parent 05d21c6e94
commit d7e926fc63
4 changed files with 12 additions and 3 deletions

View File

@ -2118,7 +2118,7 @@ static void ShowMainMenu()
nv2a_set_surface_scale_factor(rendering_scale+1);
}
if (ImGui::Combo("Scaling Mode", &scaling_mode, "Center\0Scale\0Stretch\0")) {
if (ImGui::Combo("Scaling Mode", &scaling_mode, "Center\0Scale\0Scale (Widescreen 16:9)\0Stretch\0")) {
xemu_settings_set_enum(XEMU_SETTINGS_DISPLAY_SCALE, scaling_mode);
xemu_settings_save();
}

View File

@ -81,6 +81,7 @@ struct enum_str_map {
static const struct enum_str_map display_scale_map[DISPLAY_SCALE__COUNT+1] = {
{ DISPLAY_SCALE_CENTER, "center" },
{ DISPLAY_SCALE_SCALE, "scale" },
{ DISPLAY_SCALE_WS169, "scale_ws169" },
{ DISPLAY_SCALE_STRETCH, "stretch" },
{ 0, NULL },
};

View File

@ -60,6 +60,7 @@ enum DISPLAY_SCALE
{
DISPLAY_SCALE_CENTER,
DISPLAY_SCALE_SCALE,
DISPLAY_SCALE_WS169,
DISPLAY_SCALE_STRETCH,
DISPLAY_SCALE__COUNT,
DISPLAY_SCALE_INVALID = -1

View File

@ -1165,8 +1165,15 @@ void sdl2_gl_refresh(DisplayChangeListener *dcl)
scale[0] = (float)tw/(float)ww;
scale[1] = (float)th/(float)wh;
} else {
// Scale to fit
float t_ratio = (float)tw/(float)th;
float t_ratio;
if (scaling_mode == DISPLAY_SCALE_WS169) {
// Scale to fit window using a fixed 16:9 aspect ratio
t_ratio = 16.0f/9.0f;
} else {
// Scale to fit, preserving framebuffer aspect ratio
t_ratio = (float)tw/(float)th;
}
float w_ratio = (float)ww/(float)wh;
if (w_ratio >= t_ratio) {
scale[0] = t_ratio/w_ratio;