diff --git a/Source/hwcursor.cpp b/Source/hwcursor.cpp index df67f6426..72c295a2c 100644 --- a/Source/hwcursor.cpp +++ b/Source/hwcursor.cpp @@ -46,6 +46,31 @@ enum class HotpointPosition : uint8_t { Size ScaledSize(Size size) { if (renderer != nullptr) { +#ifdef USE_SDL3 + SDL_FRect logicalDstRect; + int logicalWidth; + int logicalHeight; + if (!SDL_GetRenderLogicalPresentation(renderer, &logicalWidth, &logicalHeight, /*mode=*/nullptr)) { + LogError("SDL_GetRenderOutputSize: {}", SDL_GetError()); + SDL_ClearError(); + return size; + } + if (!SDL_GetRenderLogicalPresentationRect(renderer, &logicalDstRect)) { + LogError("SDL_GetRenderLogicalPresentationRect: {}", SDL_GetError()); + SDL_ClearError(); + return size; + } + const float dispScale = SDL_GetWindowDisplayScale(ghMainWnd); + if (dispScale == 0.0F) { + LogError("SDL_GetWindowDisplayScale: {}", SDL_GetError()); + SDL_ClearError(); + return size; + } + const float scaleX = logicalDstRect.w / static_cast(logicalWidth); + const float scaleY = logicalDstRect.h / static_cast(logicalHeight); + size.width = static_cast(static_cast(size.width) * scaleX / dispScale); + size.height = static_cast(static_cast(size.height) * scaleY / dispScale); +#else float scaleX = 1.0F; float scaleY = 1.0F; if (!SDL_GetRenderScale(renderer, &scaleX, &scaleY)) { @@ -54,6 +79,7 @@ Size ScaledSize(Size size) } size.width = static_cast(size.width * scaleX); size.height = static_cast(size.height * scaleY); +#endif } return size; }