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

Godot chooses a display scale of 1.0 despite I set my my windows to display at 150% #90885

Open
jsjtxietian opened this issue Apr 19, 2024 · 3 comments

Comments

@jsjtxietian
Copy link
Contributor

jsjtxietian commented Apr 19, 2024

Tested versions

master

System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 () - 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz (16 Threads)

Issue description

Godot chooses a display scale of 1.0 despite I set my my windows to display at 150%

Sorry for the Chinese here, but you can see I have a 2560 * 1440 monitor and I set my windows to use a 150% display scale

image

But Godot still thinks 100% is the "Auto" one:

image

Looking at the code :

const int screen = DisplayServer::get_singleton()->window_get_current_screen();
if (DisplayServer::get_singleton()->screen_get_size(screen) == Vector2i()) {
// Invalid screen size, skip.
return 1.0;
}
// Use the smallest dimension to use a correct display scale on portrait displays.
const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
// hiDPI display.
return 2.0;
} else if (smallest_dimension >= 1700) {
// Likely a hiDPI display, but we aren't certain due to the returned DPI.
// Use an intermediate scale to handle this situation.
return 1.5;
} else if (smallest_dimension <= 800) {
// Small loDPI display. Use a smaller display scale so that editor elements fit more easily.
// Icons won't look great, but this is better than having editor elements overflow from its window.
return 0.75;
}
return 1.0;

My smallest_dimension is 1440 and I have a dpi of 144, so it went into the fallback return : return 1.0;

Not sure if we can add some check to the else if (smallest_dimension >= 1700) to something like else if (smallest_dimension >= 1700 || dpi / 96 >= 1.5)

Steps to reproduce

Have the same hardware as mine and observe the auto display scale.

Minimal reproduction project (MRP)

N/A

@timothyqiu
Copy link
Member

timothyqiu commented Apr 19, 2024

DisplayServer has screen_get_max_scale() and screen_get_scale() but only implemented on macOS.

I think maybe it's time to implement these two methods on Windows with GetScaleFactorForMonitor 😜

@lostminds
Copy link

Not sure if this bug report is just for the editor, but this proposal might be related for general automatic hiDPI scaling based on system/monitor: godotengine/godot-proposals#7968

@bruvzg
Copy link
Member

bruvzg commented Apr 19, 2024

I think maybe it's time to implement these two methods on Windows with GetScaleFactorForMonitor 😜

Getting and using real scale for monitor will not work without full DPI scaling support/SHC_PROCESS_PER_MONITOR_DPI_AWARE if you have more than one monitor, so implementing screen_get_scale without it is pointless, Windows will return false values and rescale it afterwards.

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

No branches or pull requests

4 participants