Handle High DPI displays on windows

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Sasha264
Citizen
Posts: 60
Joined: Mon Sep 08, 2014 7:57 am

Handle High DPI displays on windows

Post by Sasha264 » Sat Dec 16, 2017 12:32 pm

Hello!

I am trying to run love game on 4k monitor and found some problem here.
If "font scale" in windows "screen preferences" is set up to 100% then everything works fine.
But if I change font scale to (for example) 200% then windows forces all applications to render in half resolotion and displays it scaled up by 200%. Except applications that tell windows that they can handle resolution inside correctly (for example Google chrome, Discord, modern 3d games...). They renders in full resolution as they can. My love game is not doing this, so it renders in half resolution :huh: Also love.graphics.getDimensions() returns half resolution, for example 640x480 while real game window size is 1280x960.

Is here a way to fix this?
I have tried highdpi = true in love.window.setMode, but it does nothing on windows, as the wiki tells.
Attachments
Its me.png
Its me.png (194.13 KiB) Viewed 3830 times

User avatar
Sasha264
Citizen
Posts: 60
Joined: Mon Sep 08, 2014 7:57 am

Re: Handle High DPI displays on windows

Post by Sasha264 » Fri Jan 05, 2018 3:39 am

Found one way to handle this.

Checkbox in exe file propetries.
MyGame.exe in packaged mode or love.exe in development mode.

This solves the problem perfectly on one computer: if system handles highdpi scaling (this is by default) - we have "big" pixels, otherwise we have normal pixels. But it information stores somewhere deep in OS, so after transfer to another computer this checkbox will be lost. This leads to some problems with game distributions.

Perfect solution is a way to change this inside from love dynamically. But I don't know how to do this.
Attachments
system-enhanced-scaling-option-windows10.jpg
system-enhanced-scaling-option-windows10.jpg (133.8 KiB) Viewed 3731 times

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Handle High DPI displays on windows

Post by davisdude » Fri Jan 05, 2018 3:47 am

It looks like this will be fixed in 0.11.0:
The wiki wrote:Changed high-dpi functionality to require much less code (often none at all) for graphics to appear at the correct sizes and positions.
You could try compiling it yourself or downloading a nightly build to see if that fixes the problem.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

User avatar
slime
Solid Snayke
Posts: 2853
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Handle High DPI displays on windows

Post by slime » Fri Jan 05, 2018 12:15 pm

davisdude wrote:
Fri Jan 05, 2018 3:47 am
It looks like this will be fixed in 0.11.0
Unfortunately LÖVE still doesn't support high dpi on Windows, since SDL doesnt support it yet (because Microsoft's high dpi / dpi scaling APIs are hard to work with and can't replicate the functionality of other major operating systems).

User avatar
Sasha264
Citizen
Posts: 60
Joined: Mon Sep 08, 2014 7:57 am

Re: Handle High DPI displays on windows

Post by Sasha264 » Wed Mar 20, 2019 11:13 pm

Thanks for the response!
Unfortunately, but understandable :)
...And many many games and applications have problems with that, so this "Override high DPI scaling" drop-down-box has become the most usable feature for me in past year on windows.

User avatar
Sasha264
Citizen
Posts: 60
Joined: Mon Sep 08, 2014 7:57 am

Re: Handle High DPI displays on windows

Post by Sasha264 » Tue Jul 23, 2019 4:24 pm

Found interesting note here in Additions section :awesome: https://love2d.org/wiki/11.3 :awesome:
Added 'usedpiscale' boolean (true by default) to love.window.setMode and love.conf. Disables automatic DPI scaling when false.
Will the 'usedpiscale' flag solve this high dpi problem on Windows?

User avatar
slime
Solid Snayke
Posts: 2853
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Handle High DPI displays on windows

Post by slime » Tue Jul 23, 2019 9:08 pm

No, high dpi (app-aware DPI scale) is still not supported on Windows. love's own automatic DPI scaling only happens when that's supported.

jonthysell
Prole
Posts: 12
Joined: Fri Nov 03, 2017 5:19 pm
Location: Pacific Northwest
Contact:

Re: Handle High DPI displays on windows

Post by jonthysell » Tue Jul 23, 2019 10:25 pm

When you modify the DPI settings in the file properties they get stored in the registry

From: https://superuser.com/questions/1230346 ... mmand-line

~ HIGHDPIAWARE Indicates value of Override high DPI scaling behavior (Application)

~ DPIUNAWARE Indicates value of Override high DPI scaling behavior (System)

~ GDIDPISCALING DPIUNAWARE Indicates value of Override high DPI scaling behavior (System Enhanced)

You can also set the setting temporarily in a batch file that launches your game:

Code: Select all

setlocal
pushd %~dp0\
set __COMPAT_LAYER=~ GDIDPISCALING DPIUNAWARE
love.exe game.love
popd
endlocal

User avatar
Sasha264
Citizen
Posts: 60
Joined: Mon Sep 08, 2014 7:57 am

Re: Handle High DPI displays on windows

Post by Sasha264 » Thu Jul 25, 2019 11:49 am

@slime, thanks! I will be looking forward for future updates in future years :megagrin:

@jonthysell, that's a very useful information, thank you!
Changing it permanently or temporarily through bat files is an appropriate solution :cool:

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 9 guests