From c33cf854564ef841352d7ff85b6dac264c16f030 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 21 Jun 2019 16:34:47 +0100 Subject: [PATCH] Added isGLTexture property --- src/textures/TextureSource.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/textures/TextureSource.js b/src/textures/TextureSource.js index bb5df2486..9f1e6638b 100644 --- a/src/textures/TextureSource.js +++ b/src/textures/TextureSource.js @@ -140,6 +140,15 @@ var TextureSource = new Class({ */ this.isRenderTexture = (source.type === 'RenderTexture'); + /** + * Is the source image a WebGLTexture? + * + * @name Phaser.Textures.TextureSource#isGLTexture + * @type {boolean} + * @since 3.19.0 + */ + this.isGLTexture = (source instanceof WebGLTexture); + /** * Are the source image dimensions a power of two? * @@ -187,13 +196,13 @@ var TextureSource = new Class({ this.glTexture = this.renderer.createTextureFromSource(null, this.width, this.height, this.scaleMode); } - else if (!(this.source instanceof WebGLTexture)) + else if (this.isGLTexture) { - this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + this.glTexture = this.source; } else { - this.glTexture = this.source; + this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); } } else if (this.isRenderTexture)