Skip to content

Commit 74dd09d

Browse files
committed
Add integer scaling.
1 parent e6e8283 commit 74dd09d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

config_spec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ display:
181181
default: true
182182
fit:
183183
type: enum
184-
values: [center, scale, stretch]
184+
values: [center, scale, integer, stretch]
185185
default: scale
186186
aspect_ratio:
187187
type: enum

ui/xui/gl-helpers.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,15 @@ void RenderFramebuffer(GLint tex, int width, int height, bool flip)
949949
float t_ratio = GetDisplayAspectRatio(tw, th);
950950
scale[0] = t_ratio*(float)th/(float)width;
951951
scale[1] = (float)th/(float)height;
952+
} else if (g_config.display.ui.fit == CONFIG_DISPLAY_UI_FIT_INTEGER) {
953+
// Integer scaling
954+
float t_ratio = GetDisplayAspectRatio(tw, th);
955+
int s_factor = (float)width/(float)tw;
956+
int s_height = (float)height/(float)th;
957+
if (s_height < s_factor) s_factor = s_height;
958+
if (s_factor < 1) s_factor = 1;
959+
scale[0] = s_factor*t_ratio*(int)th/(float)width;
960+
scale[1] = s_factor*(int)th/(float)height;
952961
} else {
953962
float t_ratio = GetDisplayAspectRatio(tw, th);
954963
float w_ratio = (float)width/(float)height;

ui/xui/menubar.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void ShowMainMenu()
195195
}
196196

197197
ImGui::Combo("Display Mode", &g_config.display.ui.fit,
198-
"Center\0Scale\0Stretch\0");
198+
"Center\0Scale\0Integer\0Stretch\0");
199199
ImGui::SameLine();
200200
HelpMarker("Controls how the rendered content should be scaled "
201201
"into the window");

0 commit comments

Comments
 (0)