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

Enable "Allow Hidpi" by default to fix window management issues across platforms on hiDPI monitors #3681

Closed
Calinou opened this issue Dec 16, 2021 · 6 comments · Fixed by godotengine/godot#56311
Milestone

Comments

@Calinou
Copy link
Member

Calinou commented Dec 16, 2021

Describe the project you are working on

The Godot editor 🙂

Describe the problem or limitation you are having in your project

Godot projects1 suffer from various issues when run on hiDPI monitors (such as Windows scaling set above 100%). This is most noticeable on Windows, but some problems can also pop up on macOS as a result of relying on a lowDPI fallback provided by the OS. (Linux has no concept of DPI-awareness for applications, at least on X11.)

The lowDPI fallback, as its name implies, is designed to be a fallback. While it provides better performance on integrated graphics, it is not meant to be used as a daily driver. We're effectively at the mercy of whatever the lowDPI fallback wants to do (including a lack of control over how the scaling is performed, which can result in poor scaling quality). Microsoft and Apple both encourage application developers to fix their applications to be resolution-independent, then mark their applications as DPI-aware.

This is not exclusive to modern applications/games. Some old games have received additional patches to be marked as DPI-aware by default. For games that are no longer maintained, one of the most common resolutions on PC Gaming Wiki is to disable OS-provided display scaling (aka. enabling DPI awareness). This shows that this issue is not exclusive to Godot, and that we should not try to fight the operating system's lowDPI fallback.

See godotengine/godot#29553 where this change was previously proposed. Since the original issues haven't been fixed on the OS level, I feel this is worth discussing again in 2021.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Enable the Allow Hidpi project setting by default.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

One concern about enabling Allow Hidpi by default is that performance will suffer on integrated graphics, especially in 3D games. This can be alleviated in the master branch by detecting the use of integrated graphics then defaulting to lower 3D resolution scaling (probably 50%).
If performance still proves to be an issue in 2D games, 2D resolution scaling could be implemented.

Changing a project setting's default value is a compatibility-breaking change, so a decision needs to be taken before 4.0 is released.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes, since the Allow Hidpi project setting already exists. However, the current default provides a bad experience not only for game developers, but also for their players who just want to play fullscreen games in peace 🙂

Is there a reason why this should be core and not an add-on in the asset library?

This proposal is about changing a default project setting.

Footnotes

  1. The Godot editor is always marked as DPI-aware, and is therefore not affected by this. Any project run from the editor will however be affected by this until Allow Hidpi is enabled in the Project Settings.

@Calinou Calinou added this to the 4.0 milestone Dec 16, 2021
@YuriSizov
Copy link
Contributor

I don't quite understand why it's an option at all. It should just be always on, because if it's not on, then the window of a Godot project is incorrectly scaled, looks blurry and blown out. Keeping it off only makes the experience worse for a part of users, and I doubt anyone is looking to purposefully provide worse experience.

@Calinou
Copy link
Member Author

Calinou commented Dec 17, 2021

I don't quite understand why it's an option at all.

Allow Hidpi was left as an option because disabling it does provide the fastest scaling (it's faster than using a scaled Viewport). Nonetheless, I don't think the added complications are worth it, especially when playing in fullscreen.

If you are strapped for performance, I think implementing exclusive fullscreen + resolution changes would be a better route – but this is also unreliable if the game crashes. Alternatively, people on low-end systems could use a third-party program that performs the required resolution change when a specific game is detected to be running (and then switches back to native resolution when alt-tabbing out or quitting the game).

@rainlizard
Copy link

rainlizard commented Dec 17, 2021

The reason I don't enable Allow Hidpi is because I want my UI size to look the same regardless of resolution, taking up the same percentage screen space on every person's monitor. Even if it's blurry - because being consistently the same size is preferable to being sharp and tiny. This is a downside of high resolutions like 4k, programs can often have unscaled, tiny UIs that are very difficult to see with poor eyesight. AOE2 example
I think if it could be set by the player in-game, based what works best for them personally then that might be a good solution. It looks like currently the only way to set it while in-game is by generating an override.cfg file and then prompting the user to restart the game.

EDIT: For my project I'm now enabling Allow Hidpi permanently and I've implemented a scaling option with set_screen_stretch().

@YuriSizov
Copy link
Contributor

YuriSizov commented Dec 17, 2021

The reason I don't enable Allow Hidpi is because I want my UI size to look the same regardless of resolution, taking up the same percentage screen space on every person's monitor.

In my experience, if you don't enable it, it does the exact opposite of looking the same. It just looks scaled up, because it doesn't account for system-wide scaling, which is normally set on higher density/higher resolution screens. Enabling hiDPI actually makes it look like it physically has the same size on every display.

This is a downside of high resolutions like 4k, programs can often have unscaled, tiny UIs that are very difficult to see with poor eyesight.

That is controlled with system scale factor, and by enabling hiDPI you make Godot aware of it. It doesn't look tiny, it has the proportions a user expects from every app. And you can still provide accessibility options with theming, if you want to help people with poor eyesight.

@Calinou
Copy link
Member Author

Calinou commented Dec 17, 2021

I think if it could be set by the player in-game, based what works best for them personally then that might be a good solution. It looks like currently the only way to set it in-game is by creating an override.cfg with:

Windows already allows you to force DPI awareness on and off for specific executables. macOS also allows disabling DPI awareness on a per-application basis (but not enabling it if it's disabled). We don't need to provide our own layer of customization over that – "use the platform" as they say 🙂

(We currently have a --low-dpi command line argument to forcibly disable DPI awareness, but I believe it could be removed in 4.0.)

@BigZaphod
Copy link

As a macOS/iOS user and developer and (very) part-time Godot hobbyist, I've been a bit confused by this option and wondered why it wasn't enabled by default. On iOS nearly everything has been high-DPI (retina branding) for a decade (seriously - the retina display was first introduced in 2010). The vast majority of macOS machines are laptops which have been retina for years (2012 or so) and iMacs started getting retina screens in 2014, I think. I'm not very familiar with the PC world, but I get the impression this sort of thing isn't quite as common there? As an Apple user, though, it is unbelievably jarring when something doesn't support this properly out of the box - and currently, by default, Godot projects do not.

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

Successfully merging a pull request may close this issue.

4 participants