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

feat: determine correct scale factor and native pixel resolution on windows #7

Merged
merged 10 commits into from
Feb 11, 2025

Conversation

jolexxa
Copy link
Member

@jolexxa jolexxa commented Feb 2, 2025

This is a draft until I figure out what to do about the GDExtension completely crashing the engine. Forgot you have to use the exact version that godot-dotnet is built for, currently 4.4.0-dev7. Extension works when loaded with that Godot version. Fixes #8

Since Godot does not opt into per-monitor DPI awareness on Windows (see godotengine/godot#86943 and godotengine/godot#56341), it reports certain monitor resolutions and scale factors incorrectly in multi-monitor setups when the game window is on a monitor that has a scale factor differing from the system scale factor (which is just the scale factor of the primary monitor). I have reproduced this with various displays I own and am testing with these scenarios during development. In my case, I have a 4k, QHD, and HD monitor and can vary which one is primary and what their system scale factors are in Windows.

For some reason, it's really hard to determine the true native resolution of a monitor with Win32 API's when you do not have per-monitor DPI awareness for your process. Fortunately, the GDI32 API's offer an indirect way of exposing it when creating a drawing context. I've tested on my various monitors and it seems to work across all monitors even without per-monitor DPI awareness in the Godot process, and works regardless of whether or not the monitor is itself high-DPI.

@jolexxa jolexxa marked this pull request as ready for review February 2, 2025 19:01
@jolexxa jolexxa marked this pull request as draft February 3, 2025 01:17
@jolexxa jolexxa force-pushed the feat/native-resolution branch from 1e15c79 to 9cef901 Compare February 3, 2025 23:22
@jolexxa jolexxa marked this pull request as ready for review February 11, 2025 01:45
@jolexxa jolexxa changed the title feat: determine native pixel resolution on macos/windows feat: determine correct scale factor and native pixel resolution on windows Feb 11, 2025
@jolexxa jolexxa merged commit d50561f into main Feb 11, 2025
2 checks passed
@jolexxa jolexxa deleted the feat/native-resolution branch February 11, 2025 03:05
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

Successfully merging this pull request may close these issues.

bug: scale factor not correct on Windows
1 participant