diff --git a/v3/src/gameobjects/text/static/Text.js b/v3/src/gameobjects/text/static/Text.js index 33802a698..6054cea51 100644 --- a/v3/src/gameobjects/text/static/Text.js +++ b/v3/src/gameobjects/text/static/Text.js @@ -68,6 +68,7 @@ var Text = new Class({ this.canvasTexture = null; this.prevWidth = this.canvas.width; this.prevHeight = this.canvas.height; + this.dirty = false; if (text !== '') { @@ -258,16 +259,7 @@ var Text = new Class({ } } - if (this.state.game.config.renderType === Phaser.WEBGL) - { - this.canvasTexture = this.state.game.renderer.uploadCanvasToGPU( - this.canvas, - this.canvasTexture, - !(this.prevWidth < canvas.width || this.prevHeight < canvas.height) - ); - this.prevWidth = canvas.width; - this.prevHeight = canvas.height; - } + this.dirty = true; return this; }, diff --git a/v3/src/gameobjects/text/static/TextWebGLRenderer.js b/v3/src/gameobjects/text/static/TextWebGLRenderer.js index 2d381ebbd..01b5ffcbc 100644 --- a/v3/src/gameobjects/text/static/TextWebGLRenderer.js +++ b/v3/src/gameobjects/text/static/TextWebGLRenderer.js @@ -5,6 +5,18 @@ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera return; } + if (src.dirty) + { + src.canvasTexture = renderer.uploadCanvasToGPU( + src.canvas, + src.canvasTexture, + !(src.prevWidth < src.canvas.width || src.prevHeight < src.canvas.height) + ); + src.prevWidth = src.canvas.width; + src.prevHeight = src.canvas.height; + src.dirty = false; + } + renderer.spriteBatch.addSpriteTexture(src, camera, src.canvasTexture, src.prevWidth, src.prevHeight); };