Engine window and DPI scaling

Posted By: Emre

Engine window and DPI scaling - 06/20/20 22:23

Hi guys, is there a way to ensure that the engine window is not affected by the windows dpi setting? I can get the real resolution with Superku's code (sys_metrics doesn't give the real resolution when DPI is active.) but i can't adjust the engine window to that resolution. Since my english is not good, i prepared a video to better explain the problem.Click here for video.

Any idea?

Edit: Ok, i found a workaround: Launch the application full screen, then switch to window mode.

Posted By: Dooley

Re: Engine window and DPI scaling - 06/30/20 03:49

Does this have anything to do with Ultrawide (21:9) monitors?
Posted By: Emre

Re: Engine window and DPI scaling - 06/30/20 11:27

I don't think the monitor has an effect on the event. As seen in the video, when windows dpi is active, the engine is lowering the resolution, in window mode.
Posted By: Dooley

Re: Engine window and DPI scaling - 07/13/20 15:55

"sys_metrics doesn't give the real resolution when DPI is active."

I just found this little gem in the manual...
"For retrieving the original desktop resolution, this function (sys_metrics) must be called before switching to a different fullscreen resolution - i.e. in lite-C before any level_load() or wait(), and in C-Script before any call or variable setting that would switch to fullscreen mode."

I think this was responsible for my issue (still to be tested) but perhaps you are calling on sys_metrics after a wait() or level_load() ?
Posted By: Dooley

Re: Engine window and DPI scaling - 07/13/20 23:24

Nope!
It did not solve my problem completely, but I did find out that if dpi is deactivated it starts to work correctly (where it did not before).
So I think my issue should be resolved using the same method as yours, by starting in full screen, and moving to window mode.

I will try that and report back here.
Posted By: Emre

Re: Engine window and DPI scaling - 07/14/20 10:57

Originally Posted by Dooley
So I think my issue should be resolved using the same method as yours, by starting in full screen, and moving to window mode.

Yes, i believe that's the only way and will resolve your problem. By the way, doesn't matter what sys_metrics say. You can get the real resolution with superku's code, nevertheless engine ignore that resolution in window mode. (if dpi is active.)
Posted By: Dooley

Re: Engine window and DPI scaling - 07/14/20 13:38

The player was able to overcome the issue by selecting "Disable display scaling on high DPI settings" under "Properties > Compatibility" in Windows.

Is there a way to have that active by default?
Posted By: Emre

Re: Engine window and DPI scaling - 07/14/20 14:10

Yeah i was aware of this and i did research on the internet but i couldn't find how to activate it. That was the main reason i opened this title. (:

Maybe this article can help. I have already given up. Because both my english and my programming skiil are not enough to deal with it.
Posted By: Dooley

Re: Engine window and DPI scaling - 07/14/20 14:45

Okay, the manual mentions that "The EXE file contains a manifest that is compatible to the Microsoft Games for Windows standard."

There must be a way to edit or modify that manifest ... is it built from the game's .wdl file?
Posted By: Dooley

Re: Engine window and DPI scaling - 07/14/20 20:27

Okay, I was able to reproduce the problem by setting the DPI scaling on my system to 150%, and trying to run the game in a window at 1600 x 900 (while monitor resolution was set to 1920 x 1080). This failed and opened a smaller window of 720 x 480 (or something). However, after I modified the manifest on the .exe file, as described in your link, it now works, and does not try to scale the screen up.

Here is the link on how to update the manifest: (placed here for anyone else so they don't have to read through all the posts)
https://docs.microsoft.com/en-us/windows/win32/learnwin32/dpi-and-device-independent-pixels

Now, here is a link to a program that allows you to edit the manifest:
http://www.restuner.com/download.htm

There are other ways to do this, but this seemed like the easiest. It is not a free program, but has a 30 day trial. I will probably buy it once that trial is up, since I plan to keep doing this in other projects...

To edit the manifest, first install Resource Tuner, and click yes for the context menu shortcut. Then right click on your game's executable file, and select "Open with Resource Tuner"

You will see three folders, "Icon," "Icon Group" and "Manifest." Open the Manifest folder, and double click the manifest file.

Here is what I used in my manifest.

Code
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
	<ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">
		<ms_asmv2:security>
			<ms_asmv2:requestedPrivileges>
				<ms_asmv2:requestedExecutionLevel level="asInvoker" uiAccess="false">
				</ms_asmv2:requestedExecutionLevel>
			</ms_asmv2:requestedPrivileges>
		</ms_asmv2:security>
	</ms_asmv2:trustInfo>
	<asmv3:application>
		<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
			<dpiAware>true</dpiAware>
		</asmv3:windowsSettings>
	</asmv3:application>
</assembly>


This combines the existing manifest with the additional stuff provided by the first link to Microsoft above...

For me, it now runs the game correctly, regardless of any DPI scaling. The game is not actually DPI Aware - it does not increase the size of the text or anything - but it will not think the screen is the wrong size as it was doing before.



Posted By: txesmi

Re: Engine window and DPI scaling - 07/16/20 20:41

thank you for sharing wink
Posted By: Eagle

Re: Engine window and DPI scaling - 01/26/21 04:29

This is really helpful ! Thanks
© 2024 lite-C Forums