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
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Handle High DPI displays on windows

Post by Sasha264 »

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 14015 times
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Handle High DPI displays on windows

Post by Sasha264 »

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 13916 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 »

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: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Handle High DPI displays on windows

Post by slime »

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
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Handle High DPI displays on windows

Post by Sasha264 »

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
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Handle High DPI displays on windows

Post by Sasha264 »

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: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Handle High DPI displays on windows

Post by slime »

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 »

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
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Handle High DPI displays on windows

Post by Sasha264 »

@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 5 guests