From 5bdf9aa21b8ec424a607427ba163e17d0f20b434 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 1 Oct 2018 16:32:42 +0100 Subject: [PATCH] `WebGLRenderer.deleteTexture` will check to see if the texture it is being asked to delete is the currently bound texture or not. If it is, it'll set the blank texture to be bound after deletion. This should stop `RENDER WARNING: there is no texture bound to the unit 0` errors if you destroy a Game Object, such as Text or TileSprite, from an async or timed process --- CHANGELOG.md | 2 ++ src/renderer/webgl/WebGLRenderer.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67cb53d6f..84a0d5c4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Updates +* `WebGLRenderer.deleteTexture` will check to see if the texture it is being asked to delete is the currently bound texture or not. If it is, it'll set the blank texture to be bound after deletion. This should stop `RENDER WARNING: there is no texture bound to the unit 0` errors if you destroy a Game Object, such as Text or TileSprite, from an async or timed process (thanks jamespierce) + ### Bug Fixes ### Examples and TypeScript diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index 50625259a..c0d2b75a8 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -1470,6 +1470,12 @@ var WebGLRenderer = new Class({ this.gl.deleteTexture(texture); + if (this.currentTextures[0] === texture) + { + // texture we just deleted is in use, so bind a blank texture + this.setBlankTexture(true); + } + return this; },