Skip to content

Commit d4d606c

Browse files
committed
Centered scaling now uses offsets for a clean image.
1 parent bd2a0b4 commit d4d606c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ui/xui/gl-helpers.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,14 @@ void RenderFramebuffer(GLint tex, int width, int height, bool flip)
948948
} else if (g_config.display.ui.fit == CONFIG_DISPLAY_UI_FIT_CENTER) {
949949
// Centered
950950
float t_ratio = GetDisplayAspectRatio(tw, th);
951-
scale[0] = t_ratio*(float)th/(float)width;
952-
scale[1] = (float)th/(float)height;
951+
int fb_height = th;
952+
int fb_width = (int)(fb_height * t_ratio);
953+
offset_x = (width - fb_width) / 2;
954+
offset_y = (height - fb_height) / 2;
955+
width = fb_width;
956+
height = fb_height;
957+
scale[0] = 1.0;
958+
scale[1] = 1.0;
953959
} else if (g_config.display.ui.fit == CONFIG_DISPLAY_UI_FIT_INTEGER) {
954960
// Integer scaling
955961
float t_ratio = GetDisplayAspectRatio(tw, th);

0 commit comments

Comments
 (0)