diff options
Diffstat (limited to 'scene/main/window.cpp')
-rw-r--r-- | scene/main/window.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 64869b2936..dc04941ae7 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -668,6 +668,7 @@ void Window::_update_viewport_size() { Rect2i attach_to_screen_rect(Point2i(), size); Transform2D stretch_transform; float font_oversampling = 1.0; + window_transform = Transform2D(); if (content_scale_mode == CONTENT_SCALE_MODE_DISABLED || content_scale_size.x == 0 || content_scale_size.y == 0) { font_oversampling = content_scale_factor; @@ -754,11 +755,18 @@ void Window::_update_viewport_size() { Size2 scale = Vector2(screen_size) / Vector2(final_size_override); stretch_transform.scale(scale); + window_transform.translate_local(margin); } break; case CONTENT_SCALE_MODE_VIEWPORT: { final_size = (viewport_size / content_scale_factor).floor(); attach_to_screen_rect = Rect2(margin, screen_size); + window_transform.translate_local(margin); + if (final_size.x != 0 && final_size.y != 0) { + Transform2D scale_transform; + scale_transform.scale(Vector2(attach_to_screen_rect.size) / Vector2(final_size)); + window_transform *= scale_transform; + } } break; } } |