How to get Windows Desktop scale?

I have developed and shipped a game and everything was fine until I started to get reports about game window being too big on windowed & fullscreen mode.

After a while, I have figured it out that if you have anything else than 100% Windows Dekstop scale it will mess up resolutions.

QUESTION: Is there a way to get the Windows Dekstop scale factor somehow? Or at least the original resolution without scaling?

EXAMPLE: My desktop resolution is set to 1920x1080 but my scale is 125%.
This means that windowed mode of 960x540 will be actually 1200x675

The same goes for the fullscreen mode where in this case, only 75% of the screen is visible. If I could get my hands on that scale factor I could fix the viewport accordingly.

Thank you!

image

I think it’s a flag in Visual Studio’s solution properties. I’m not sure how far back it goes (VS15?), but you just set it to tell Windows that your game will handle window scaling.

Solution properties > Configuration Properties > Manifest Tool > Input and Output > DPI Awareness > “Per Monitor High DPI Aware”

Definitely read this article since there’s more to it than that.

Also read this article from Microsoft.

2 Likes

And just like that, my game is working perfectly on any scale, thank you so much! I just had to change the solution property you have suggested.

I honestly couldn’t find the solution before and I quit many times since I received the first bug report. Hopefully this will work for others as well.

Once again, thank you for the help and for the article, it helps a lot! :+1: