From 5812b4b7a70a09c979ffdacc3941c7926cca5928 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 3 Nov 2023 19:02:52 +0000 Subject: [PATCH] Fixed issue with Dynamic Textures and Render Textures not displaying until resized. Fix #6662 --- src/textures/DynamicTexture.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/textures/DynamicTexture.js b/src/textures/DynamicTexture.js index d20ab77d2..2052b148f 100644 --- a/src/textures/DynamicTexture.js +++ b/src/textures/DynamicTexture.js @@ -108,7 +108,7 @@ var DynamicTexture = new Class({ * @type {number} * @since 3.60.0 */ - this.width = width; + this.width = -1; /** * The height of this Dynamic Texture. @@ -119,7 +119,7 @@ var DynamicTexture = new Class({ * @type {number} * @since 3.60.0 */ - this.height = height; + this.height = -1; /** * This flag is set to 'true' during `beginDraw` and reset to 'false` in `endDraw`, @@ -228,12 +228,7 @@ var DynamicTexture = new Class({ if (!isCanvas) { - var frame = this.get(); - var textureSource = frame.source; - - textureSource.isRenderTexture = true; - textureSource.isGLTexture = true; - textureSource.glTexture.flipY = true; + this.setSize(width, height); } }, @@ -274,10 +269,13 @@ var DynamicTexture = new Class({ if (renderTarget) { - renderTarget.resize(width, height); + if (renderTarget.willResize(width, height)) + { + renderTarget.resize(width, height); - // The WebGLTexture has been resized, so is new, so we need to delete the old one - this.renderer.deleteTexture(source.glTexture); + // The WebGLTexture has been resized, so is new, so we need to delete the old one + this.renderer.deleteTexture(source.glTexture); + } this.setFromRenderTarget(); }