X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=7221c7afeede8e9655e005b63d98bb8c4e1b51e0;hp=9ed0e49da6bc6367e88ae84be0c781780abd2fe1;hb=00383dd409fde133c6738231abfcee662c03087c;hpb=67b32ebb347487d2d3a9d926ad8d1c4ed3d9aec6;ds=sidebyside diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 9ed0e49d..7221c7af 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -2753,8 +2753,28 @@ static void DrawTouchInputOverlay() alpha_last = alpha; + float ratio_overlay = (float) width / height; + float ratio_screen = (float) video.screen_width / video.screen_height; + int width_scaled, height_scaled; + int xpos, ypos; + + if (ratio_overlay > ratio_screen) + { + width_scaled = video.screen_width; + height_scaled = video.screen_height * ratio_screen / ratio_overlay; + xpos = 0; + ypos = video.screen_height - height_scaled; + } + else + { + width_scaled = video.screen_width * ratio_overlay / ratio_screen; + height_scaled = video.screen_height; + xpos = (video.screen_width - width_scaled) / 2; + ypos = 0; + } + SDL_Rect src_rect = { 0, 0, width, height }; - SDL_Rect dst_rect = { 0, 0, video.screen_width, video.screen_height }; + SDL_Rect dst_rect = { xpos, ypos, width_scaled, height_scaled }; SDL_RenderCopy(sdl_renderer, texture, &src_rect, &dst_rect); #endif