summaryrefslogtreecommitdiffstats
path: root/scene/resources/texture.cpp
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2021-08-13 12:32:01 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2021-08-13 12:32:01 +0300
commit8f70232a15c09703190e4b2d43ef6726c0f60aa4 (patch)
tree2de5390602736444d41325e83d0901fb8cdd04fe /scene/resources/texture.cpp
parent39efccf3b8298e30aa67a726ffd8752b3dff4c66 (diff)
downloadredot-engine-8f70232a15c09703190e4b2d43ef6726c0f60aa4.tar.gz
Add placeholder textures to ensure CameraTexture / CameraFeed always have valid RIDs.
Diffstat (limited to 'scene/resources/texture.cpp')
-rw-r--r--scene/resources/texture.cpp9
1 files changed, 7 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);
+ }
}