-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Viewport size conflictingly doubled when using "Allow Hidpi" and stretch settings "2d" and "expand" #28666
Comments
I'm having the same issue in Godot 3.1.1-stable.official. My use case: a custom tooltip-like window that follows the mouse, but has to stay inside the screen so it's clamped using the viewport size. Using HiDpi all my mouse position measures are still relative to the "test size" but the viewport size is doubled, breaking the use case. I haven't found any way to solve this so it seems like a bug to me, or a missing "get viewport scale factor" feature. By the way, this use case is also affected by the #28665 issue. Also my system specs, to add more information on the issue: |
Thanks for your input, @LucidTaZ! If you're still looking for a workaround, I wrote a small function in the attached project that calculates the actual size of the viewport. I'll paste it here for convenience (I also added some additional static typing):
This would work well in a singleton (AutoLoad) script so it can be accessed from anywhere. Hope this helps! |
Actually I just tried out your minimal reproduction project but compared the values to Here's your modified example: |
Seems fixed in 3.2.4 beta4 |
|
So according to that comment this is a platform-specific issue. |
Godot version: v3.1.stable.official
OS: macOS Mojave 10.14.4
Device: 13" 2017 MacBook Pro w/ 4 Thunderbolt 3 Ports
GPU: Intel Iris Plus Graphics 650
Display: 2560x1600 Retina
Issue description:
This is sort of related to issue #28665, but I figured this issue was different enough to post separately.
When using "Allow Hidpi" and stretch settings "2d" and "expand", the viewport size returned by
get_viewport().size
is always double the size defined in the project settings file. However, the mouse position and objects in the scene are positioned using the non-doubled size. For example, placing an object atget_viewport().size.x
would move it completely out of view of the window, however placing it atget_viewport().size.x / 2.0
would properly place it on the right edge of the window.I'm not sure whether this is intended or not, but I find this behavior odd as it appears that objects in the scene are not positioned using the Hidpi setting.
The attached minimal reproduction project displays the following values to highlight the discrepancies between them:
Notice how the positions of the mouse and square when moving them to the right or bottom edges of the window do not match the width/height reported by
get_viewport().size
.Steps to reproduce:
Minimal reproduction project: ViewportBugHidpiProject.zip
(This is the exact same project from issue #28665, except "Allow Hidpi" is checked in the project settings)
The text was updated successfully, but these errors were encountered: