-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve game UI scale on small screen sizes #31083
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A easy to digest PR 🙂
The fix to scaling would be great for small mobile devices! 🚀
The tests failing should be addressed and the hard-coded base_target_draw_size
would ideally be configurable and not hard-coded at this level. However, depending on why this is, it may be more or less feasible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that shows that this cannot fix the Android issue without SDL providing a pre-scaled window resolution for |
This PR should actually be using https://wiki.libsdl.org/SDL3/SDL_GetWindowDisplayScale, which reports correct values on windows (haven't yet tested android): 200% display scale will yield 2.0f. Could you update your code to use |
I would hope we use the seemingly new API you mentioned directly on the |
That would break most existing usages of
Display scale and pixel density are orthogonal concepts. Depending on the context, it makes sense to apply one or the other. |
Looks like Android does indeed return the pixel density through the API you suggested: https://github.com/libsdl-org/SDL/blob/6cc9ce183d904489bf8e33e26b91d6012667e1b0/src/video/android/SDL_androidvideo.c#L181 |
As it turns out, SDL provides sane window size dimensions for iPhones, e.g. 852x393 on iPhone 16. We can use that information to construct an algorithm at a
ScalingContainer
level which ensures the game does not descale on small window sizes (inspired by previous discussions on the matter, mainly #21335 (comment)).Preview on mobile: