Godot: 2D and Viewport stretch modes fail on Windows fullscreen with desktop display scaling

Created on 1 Oct 2017  路  5Comments  路  Source: godotengine/godot

Windows 10 64-bit (NVIDIA)
Godot 2.1.4
NVIDIA 1070 - driver 385.69,

Issue description:
Display scaling via Viewport and 2D doesn't work correctly on game when the game is fullscreen (only when it is fullscreen) AND Windows Display Settings Scale is different than 100% (which is very common today for them to be set greater than 100%). The behavior works correctly on Linux and OSX. I even adjusted scaling on OSX and behavior is good, but on Windows the scale is incorrect. In debugging the problem I found that if I print the screen size and the viewport size, they match in all of the working cases. However, in the fullscreen Windows Display Scale > 100% case, the viewport is the native resolution of the screen (1920x1080), but the screen may be something smaller due to scaling. I suspect the viewport is not getting set correctly when Windows Display Scale is > 100% and the game is fullscreen. However the screen size is getting set correctly. Toggling the HIDPI settings doesn't make a difference either.

Hopefully I explained this well enough. I know the user can right-click the application and set properties > compatibility > ignore scaling as an option, but they shouldn't have to do this. I supplied a sample project (ScalingExample) and a video demonstrating the behavior (errordemo)

In the meantime I will try to adjust the viewport manually on startup.

Steps to reproduce:
_Demonstrate fullscreen without display scaling works correctly_
In Windows 10 set your project settings as follows:

  • Fullscreen (true)
  • Stretch Mode (2d or viewport - I used 2d for the example)
  • Stretch Aspect (keep - I've also tried the others)
    Run the application
    The game should render correctly
    Stop the game

_Demonstrate no fullscreen and resizing works correctly_
Open Windows Display Settings and make sure "Scale and Layout" is set to 100%.
Change Project Settings > Fullscreen > False
Run the application
Resize your window, the application should render correctly at the correct scale.
Stop the game

_Demonstrate no fullscreen and resizing with Desktop Display Scaling works correctly_
Open Windows Display Settings and make sure "Scale and Layout" is > 100%
Make sure Project Settings > Fullscreen > False
Run the application
Run the application and resize the window
The application should render correctly.
Stop the game

_Demonstrate Error Condition - fullscreen with Desktop Display Scaling renders incorrectly_
Open Windows Display Settings and make sure "Scale and Layout" is > 100%
Change Project Settings > Fullscreen > True
Run the application
The graphics will be scaled much larger than they should be and may be off screen
Stop the game

Link to minimal example project:
ScalingExample.zip
errordemo.zip

bug rendering

Most helpful comment

This is because the Godot executables aren't marked as DPI-aware, but last time it was attempted, it caused them to crash on Intel HD Graphics 3000 (Sandy Bridge IGPs). However, these won't be supported in Godot 3.0, so the executables might as well be marked as DPI-aware now.

All 5 comments

This is because the Godot executables aren't marked as DPI-aware, but last time it was attempted, it caused them to crash on Intel HD Graphics 3000 (Sandy Bridge IGPs). However, these won't be supported in Godot 3.0, so the executables might as well be marked as DPI-aware now.

I just finished smoke testing my fix by putting SetProcessDPIAware in the OS_Windows::initialize code on the 2.1.4 code base. Are there any plans to do another 2.1.x drop or is the next drop 3.0? I guess I'm asking - should I clean up my code and open a pull request or is it a mute point with 3.0?

Still remains an issue in 3.0. Changing the Windows Display Settings Scale to something greater than 100% results in a smaller than expected screen in the .exe.

Still remains an issue in 3.0. Changing the Windows Display Settings Scale to something greater than 100% results in a smaller than expected screen in the .exe.

The project's default window size currently won't automatically scale based on the user's DPI setting, this is a known issue. This also applies to the Project Manager window, see https://github.com/godotengine/godot/issues/8543.

This could be done easily, but will break the appearance of projects that don't support multiple resolutions at all (which should be uncommon today, but this may make it more difficult for newcomers to learn Godot if they're using hiDPI displays).

This issue was fixed by me a while ago, so closing. Feel free to reopen if you still see it happening.

Was this page helpful?
0 / 5 - 0 ratings