From 9bbc402b810d0dc3f03ea96c0cabb003ebe2d37c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 25 Jan 2023 10:20:44 -0800 Subject: [PATCH] Take the display scale into account in SDL_GetWindowSizeInPixels() --- src/video/SDL_video.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index b413d0394..cb8e01ed3 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2395,7 +2395,15 @@ void SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) if (_this->GetWindowSizeInPixels) { _this->GetWindowSizeInPixels(_this, window, w, h); } else { + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + SDL_GetWindowSize(window, w, h); + + if (display) + { + *w = (int)SDL_ceilf(*w * display->current_mode.display_scale); + *h = (int)SDL_ceilf(*h * display->current_mode.display_scale); + } } }