summaryrefslogtreecommitdiff
path: root/scene/main/viewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r--scene/main/viewport.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 412632acfc..0e658f7edd 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -74,7 +74,13 @@ void ViewportTexture::setup_local_to_scene() {
vp->viewport_textures.insert(this);
- VS::get_singleton()->texture_set_proxy(proxy, vp->texture_rid);
+ if (proxy_ph.is_valid()) {
+ VS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid);
+ VS::get_singleton()->free(proxy_ph);
+ } else {
+ ERR_FAIL_COND(proxy.is_valid()); //should be invalid
+ proxy = VS::get_singleton()->texture_proxy_create(vp->texture_rid);
+ }
}
void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
@@ -112,6 +118,10 @@ Size2 ViewportTexture::get_size() const {
RID ViewportTexture::get_rid() const {
//ERR_FAIL_COND_V_MSG(!vp, RID(), "Viewport Texture must be set to use it.");
+ if (proxy.is_null()) {
+ proxy_ph = VS::get_singleton()->texture_2d_placeholder_create();
+ proxy = VS::get_singleton()->texture_proxy_create(proxy_ph);
+ }
return proxy;
}
@@ -146,6 +156,9 @@ ViewportTexture::~ViewportTexture() {
vp->viewport_textures.erase(this);
}
+ if (proxy_ph.is_valid()) {
+ VS::get_singleton()->free(proxy_ph);
+ }
VS::get_singleton()->free(proxy);
}
@@ -3309,7 +3322,7 @@ Viewport::Viewport() {
default_texture.instance();
default_texture->vp = const_cast<Viewport *>(this);
viewport_textures.insert(default_texture.ptr());
- VS::get_singleton()->texture_set_proxy(default_texture->proxy, texture_rid);
+ default_texture->proxy = VS::get_singleton()->texture_proxy_create(texture_rid);
//internal_listener = SpatialSoundServer::get_singleton()->listener_create();
audio_listener = false;