summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/texture.cpp9
-rw-r--r--scene/resources/texture.h1
2 files changed, 8 insertions, 2 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 2ea55843ad..4ad5f2a506 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -2587,7 +2587,10 @@ RID CameraTexture::get_rid() const {
if (feed.is_valid()) {
return feed->get_texture(which_feed);
} else {
- return RID();
+ if (_texture.is_null()) {
+ _texture = RenderingServer::get_singleton()->texture_2d_placeholder_create();
+ }
+ return _texture;
}
}
@@ -2643,5 +2646,7 @@ bool CameraTexture::get_camera_active() const {
CameraTexture::CameraTexture() {}
CameraTexture::~CameraTexture() {
- // nothing to do here yet
+ if (_texture.is_valid()) {
+ RenderingServer::get_singleton()->free(_texture);
+ }
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 98aa61138d..2e97c2deb1 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -812,6 +812,7 @@ class CameraTexture : public Texture2D {
GDCLASS(CameraTexture, Texture2D);
private:
+ mutable RID _texture;
int camera_feed_id = 0;
CameraServer::FeedImage which_feed = CameraServer::FEED_RGBA_IMAGE;