Improved DPI awareness


#1

Hey, I appreciate it very much that since 2.0.4 you can get the current pixel density of the display (DPI). But there is a problem:

In order to adapt graphical user interfaces, for example, you need a scaling factor. And to calculate this, you need the default DPI of the display. But these are different among the platforms. Under Windows it is 96 DPI. With my laptop, for example, with 120 DPI, there is a scaling factor of 120/96=1.25. But I’ve heard that Apple, for example, has 72 DPI by default. Unfortunately you can’t find good resources on the internet and since I don’t have a Mac, I can’t test it :frowning:

Therefore I would like to wish for a function like SDL_GetDisplayDefaultDPI(…) to scale reliably on all platforms.

What do you think?
Best regards


#2

I suspect maybe the reason why this isn’t on SDL is because there’s no way to detect that on each OS? Might be wrong. I haven’t found a way to detect that by system either, the only thing closed is that on Windows instead of hardcoding the 96 we can at least use
USER_DEFAULT_SCREEN_DPI macro. (WinUser.h)

I’ve been using harcoded 72 for Mac and 96 for Linux, if anyone knows knows a better way to detect that could be cool.