Skip to content

Commit 16e687c

Browse files
committed
Fixed issue with FBO leaving no bound texture on unit zero.
1 parent 181e08a commit 16e687c

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/renderer/webgl/QuadFBO.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ Phaser.Renderer.WebGL.QuadFBO.prototype = {
115115

116116
this.createShader();
117117

118+
this.emptyTexture = this.renderer.createEmptyTexture(1, 1, 0, 0);
119+
118120
// Reset back to defaults
119-
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
120-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
121+
// gl.bindRenderbuffer(gl.RENDERBUFFER, null);
122+
// gl.bindFramebuffer(gl.FRAMEBUFFER, null);
121123
},
122124

123125
// This whole function ought to be split out into the Shader Manager
@@ -295,8 +297,10 @@ Phaser.Renderer.WebGL.QuadFBO.prototype = {
295297

296298
this.renderer.drawCount++;
297299

298-
// Unbind the fbo texture - if we forget this we corrupt the main context texture!
299-
gl.bindTexture(gl.TEXTURE_2D, null);
300+
// Unbind the fbo texture and replace it with an empty texture.
301+
// If we forget this we corrupt the main context texture!
302+
// or get `RENDER WARNING: there is no texture bound to the unit 0` spam in the console
303+
gl.bindTexture(gl.TEXTURE_2D, this.emptyTexture);
300304
},
301305

302306
destroy: function ()

src/renderer/webgl/WebGLRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ Phaser.Renderer.WebGL.prototype = {
322322

323323
if (Array.isArray(textureArray))
324324
{
325-
// index 0 is reserved!
325+
// index 0 is reserved?
326326
var index = 0;
327327

328328
for (var i = 0; i < textureArray.length; i++)

0 commit comments

Comments
 (0)