feat: determine correct scale factor and native pixel resolution on windows #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 #8Since 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.