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)