Skip to content

Commit 822f9b9

Browse files
committed
Snap output window to framebuffer pixel grid
1 parent 14f8bf6 commit 822f9b9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

platforms/shared/desktop/gui.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,18 @@ static void main_window(void)
609609
float tex_h = (float)runtime.screen_width / (float)(SYSTEM_TEXTURE_WIDTH);
610610
float tex_v = ((float)runtime.screen_height * (float)ogl_renderer_output_scale) / (float)(FRAME_BUFFER_HEIGHT);
611611

612-
ImGui::Image((ImTextureID)(intptr_t)ogl_renderer_emu_texture, ImVec2(window_width, window_height), ImVec2(0, 0), ImVec2(tex_h, tex_v));
612+
if (fractional_fb_scale)
613+
{
614+
float uv_x0 = 0.5f / (float)FRAME_BUFFER_WIDTH;
615+
float uv_y0 = 0.5f / (float)FRAME_BUFFER_HEIGHT;
616+
float uv_x1 = ((float)runtime.screen_width - 0.5f) / (float)FRAME_BUFFER_WIDTH;
617+
float uv_y1 = (((float)runtime.screen_height * (float)ogl_renderer_output_scale) - 0.5f) / (float)FRAME_BUFFER_HEIGHT;
618+
ImGui::Image((ImTextureID)(intptr_t)ogl_renderer_emu_texture, ImVec2(window_width, window_height), ImVec2(uv_x0, uv_y0), ImVec2(uv_x1, uv_y1));
619+
}
620+
else
621+
{
622+
ImGui::Image((ImTextureID)(intptr_t)ogl_renderer_emu_texture, ImVec2(window_width, window_height), ImVec2(0, 0), ImVec2(tex_h, tex_v));
623+
}
613624

614625
if (config_video.fps)
615626
gui_show_fps();

0 commit comments

Comments
 (0)