platform sdl, fix minor bug in window size handling

This commit is contained in:
kub 2023-02-12 22:51:44 +00:00
parent e64742875a
commit 5aa5700685
2 changed files with 22 additions and 7 deletions

View file

@ -161,6 +161,14 @@ void plat_video_set_size(int w, int h)
} }
} }
void plat_video_set_shadow(int w, int h)
{
g_screen_width = w;
g_screen_height = h;
g_screen_ppitch = w;
g_screen_ptr = shadow_fb;
}
void plat_video_flip(void) void plat_video_flip(void)
{ {
resize_buffers(); resize_buffers();
@ -292,8 +300,13 @@ void plat_video_loop_prepare(void)
// switch over to scaled output if available, but keep the aspect ratio // switch over to scaled output if available, but keep the aspect ratio
if (plat_sdl_overlay || plat_sdl_gl_active) { if (plat_sdl_overlay || plat_sdl_gl_active) {
g_screen_width = (240 * g_menuscreen_w / g_menuscreen_h) & ~1; if (g_menuscreen_w * 240 >= g_menuscreen_h * 320) {
g_screen_height = 240; g_screen_width = (240 * g_menuscreen_w/g_menuscreen_h) & ~1;
g_screen_height= 240;
} else {
g_screen_width = 320;
g_screen_height= (320 * g_menuscreen_h/g_menuscreen_w) & ~1;
}
g_screen_ppitch = g_screen_width; g_screen_ppitch = g_screen_width;
g_screen_ptr = shadow_fb; g_screen_ptr = shadow_fb;
} }
@ -317,10 +330,12 @@ void plat_early_init(void)
static void plat_sdl_resize(int w, int h) static void plat_sdl_resize(int w, int h)
{ {
// take over new settings // take over new settings
if (plat_sdl_screen->w != area.w || plat_sdl_screen->h != area.h) {
g_menuscreen_h = plat_sdl_screen->h; g_menuscreen_h = plat_sdl_screen->h;
g_menuscreen_w = plat_sdl_screen->w; g_menuscreen_w = plat_sdl_screen->w;
resize_buffers(); resize_buffers();
rendstatus_old = -1; rendstatus_old = -1;
}
} }
static void plat_sdl_quit(void) static void plat_sdl_quit(void)

View file

@ -442,7 +442,7 @@ void pemu_loop_prep(void)
void pemu_loop_end(void) void pemu_loop_end(void)
{ {
/* do one more frame for menu bg */ /* do one more frame for menu bg */
plat_video_set_size(320, 240); plat_video_set_shadow(320, 240);
pemu_forced_frame(0, 1); pemu_forced_frame(0, 1);
g_menubg_src_w = g_screen_width; g_menubg_src_w = g_screen_width;
g_menubg_src_h = g_screen_height; g_menubg_src_h = g_screen_height;