mirror of
https://github.com/godotengine/godot.git
synced 2025-01-22 02:22:20 -05:00
Merge pull request #101700 from scgm0/Fix-ViewportTexture--get_size
Fix `ViewportTexture::get_size`
This commit is contained in:
commit
b5737f897e
1 changed files with 13 additions and 4 deletions
|
@ -126,7 +126,10 @@ int ViewportTexture::get_width() const {
|
|||
_err_print_viewport_not_set();
|
||||
return 0;
|
||||
}
|
||||
return get_size().width;
|
||||
if (vp->is_sub_viewport()) {
|
||||
return vp->size.width;
|
||||
}
|
||||
return vp->size.width * vp->get_stretch_transform().get_scale().width;
|
||||
}
|
||||
|
||||
int ViewportTexture::get_height() const {
|
||||
|
@ -134,7 +137,10 @@ int ViewportTexture::get_height() const {
|
|||
_err_print_viewport_not_set();
|
||||
return 0;
|
||||
}
|
||||
return get_size().height;
|
||||
if (vp->is_sub_viewport()) {
|
||||
return vp->size.height;
|
||||
}
|
||||
return vp->size.height * vp->get_stretch_transform().get_scale().height;
|
||||
}
|
||||
|
||||
Size2 ViewportTexture::get_size() const {
|
||||
|
@ -142,8 +148,11 @@ Size2 ViewportTexture::get_size() const {
|
|||
_err_print_viewport_not_set();
|
||||
return Size2();
|
||||
}
|
||||
float scale = MIN(vp->get_screen_transform().get_scale().width, vp->get_screen_transform().get_scale().height);
|
||||
return Size2(vp->size.width * scale, vp->size.height * scale).ceil();
|
||||
if (vp->is_sub_viewport()) {
|
||||
return vp->size;
|
||||
}
|
||||
Size2 scale = vp->get_stretch_transform().get_scale();
|
||||
return Size2(vp->size.width * scale.width, vp->size.height * scale.height).ceil();
|
||||
}
|
||||
|
||||
RID ViewportTexture::get_rid() const {
|
||||
|
|
Loading…
Reference in a new issue