-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add methods to get device pixel ratio #249
Add methods to get device pixel ratio #249
Conversation
58afd20
to
df7fbd4
Compare
This looks good, and is basically the same as how I've seen other engines implement this 👍 The only thing I'm not sure about is returning seperate values for the width and height ratio - is there any scenario where those values would not be the same? If not, then it might be worth just returning a single value (which is what Love2D and the web API you linked do). |
Since I thought that there might be some very strange display devices in the world, and that there might be a rare possibility that they might appear in the future, and since I thought that a non-square HIDPI scale might be set by hacking, I decided to return two values in this function. However, I think all of these cases are either very rare or impossible, so I have no objection to modifying this function to return a single value. Which would be better? windows - Are pixels ever not a square on a monitor? - Stack Overflow |
It seems to be guaranteed that x and y will be on the same scale in Windows. GetDpiForMonitor function (shellscalingapi.h) - Win32 apps | Microsoft Docs
|
Done a little digging:
So while I think theoretically displays can have non-square pixels, it doesn't look like OSes really expose this in any meaningful way, so it's probably better to just return a single value. If anyone comes along that desperately needs non-uniform scale factors, I can change it later/add a new method 😄 |
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.
🚀
Fixed. If you don't like the name of this function, feel free to change it to |
Thanks for the PR! I may switch the name to your suggestion, just for consistency with the existing |
@sumibi-yakitori FYI, I've also added a |
Thank you for taking the time to tell me about this. Lately, I've been spending a lot of time thinking about whether I should get out of Tokyo, where I live, and I haven't been able to concentrate on development work... |
This method allows you to get the pixel ratio of the display on which the current window is displayed, which is more convenient than
SDL_GetDisplayDPI
References: