Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 7, 8 and 10 needs apps to be DPI-aware #141

Open
BenMcLean opened this issue Nov 21, 2016 · 0 comments
Open

Windows 7, 8 and 10 needs apps to be DPI-aware #141

BenMcLean opened this issue Nov 21, 2016 · 0 comments

Comments

@BenMcLean
Copy link

I first wrote this issue up for libGDX here libgdx/libgdx#3813 only to find out that it's probably a LWJGL issue. My post is below -- everything I say about libGDX is, I believe, really coming from LWJGL.

On Windows 10, there is a feature called UI Scaling described in this article: https://www.thurrott.com/windows/windows-10/4597/windows-10-feature-focus-display-scaling

This is a good feature for people with vision problems to make the text and GUI elements bigger in most Windows programs.

However, when this feature is enabled, two very bad things happen for libGDX:

  1. In full screen mode, we only see the upper left portion of the viewport zoomed in according to the degree of the UI scaling.

  2. Nearest Neighbor pixel rendering screws up and shows blurry pixels instead of sharp edges. (this becomes easier to see with Windows Magnifier, but it's happening and it's nasty)

I have confirmed this by running my program with UI scaling turned off (it works perfect) then turning UI scaling on. (these bad effects happen)

This feature first started on Windows XP but programmers only started having to worry about it when Windows 7 started trying to scale up apps that didn't tell the newer Windows API that they were DPI-aware. I believe that is what the problem is for libGDX. As InfoWorld says, "For apps that aren't high-DPI aware, Microsoft has a quick and dirty fix called DPI virtualization. Windows deliberately reports the wrong DPI resolution to such apps, so their elements render as if they were on a lower-resolution display. The results are then zoomed to fit the current display." http://www.infoworld.com/article/2952506/microsoft-windows/high-resolution-displays-reveal-windows-10-blind-spot.html

What needs to be done to fix this is to make Windows builds of libGDX apps DPI-aware, as discussed in this article from Microsoft https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx and explained in this tutorial. https://msdn.microsoft.com/en-us/library/windows/desktop/dd464659(v=vs.85).aspx

Here is a really good blog post about the issue: http://www.hanselman.com/blog/LivingAHighDPIDesktopLifestyleCanBePainful.aspx

If you'd like to see my code, here is the commit I tested this effect on: BenMcLean/badroguelike@31afc8f

As a temporary workaround, libGDX game developers can turn off UI scaling before running the libGDX apps, then turn it back on afterwards to write code, and players can check the "Disable display scaling on high DPI settings" check box under "Compatibility" in the Properties for the app. But that is a real pain to deal with and DPI-awareness is a necessity for Windows apps now.

The wiki indicates the LWJGL only has a high DPI mode implemented for OSX. http://wiki.lwjgl.org/wiki/Using_High_DPI_Mode.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant