Skip to content

Commit 50a3555

Browse files
RenderTexture: Texture is always destroyed
Texture is now destroyed only if it was not saved to the TextureManager, so it can be reused.
1 parent 3cc17f5 commit 50a3555

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/gameobjects/rendertexture/RenderTexture.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ var RenderTexture = new Class({
161161

162162
// Get the frame
163163
this.frame = this.texture.get();
164+
165+
this._saved = false;
164166

165167
/**
166168
* An internal Camera that can be used to move around the Render Texture.
@@ -350,6 +352,8 @@ var RenderTexture = new Class({
350352
saveTexture: function (key)
351353
{
352354
this.textureManager.renameTexture(this.texture.key, key);
355+
356+
this._saved = true;
353357

354358
return this.texture;
355359
},
@@ -835,7 +839,7 @@ var RenderTexture = new Class({
835839
this.renderer.deleteFramebuffer(this.framebuffer);
836840
}
837841

838-
this.texture.destroy();
842+
if (!this._saved) this.texture.destroy();
839843
}
840844

841845
});

0 commit comments

Comments
 (0)