Skip to content

Commit 0dee115

Browse files
committed
PIXI.WebGLRenderer.updateTexture now returns a boolean depending on if the texture was successfully bound to the gl context or not.
PIXI.WebGLSpriteBatch.renderBatch would still try and render a texture even if `updateTexture` failed to bind it. It now checks the return value from `updateTexture` and ignores failed binds.
1 parent 2633f8c commit 0dee115

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
304304

305305
### Pixi Updates
306306

307+
Please note that Phaser uses a custom build of Pixi (and always has done), the following changes are those made to our custom build, not to Pixi in general.
308+
307309
* CanvasRenderer.mapBlendModes optimised to cut down on file size.
310+
* PIXI.WebGLRenderer.updateTexture now returns a boolean depending on if the texture was successfully bound to the gl context or not.
311+
* PIXI.WebGLSpriteBatch.renderBatch would still try and render a texture even if `updateTexture` failed to bind it. It now checks the return value from `updateTexture` and ignores failed binds.
308312

309313
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
310314

src/pixi/renderers/webgl/WebGLRenderer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,13 @@ PIXI.WebGLRenderer.prototype.resize = function(width, height)
348348
*
349349
* @method updateTexture
350350
* @param texture {Texture} the texture to update
351+
* @return {boolean} True if the texture was successfully bound, otherwise false.
351352
*/
352353
PIXI.WebGLRenderer.prototype.updateTexture = function(texture)
353354
{
354355
if (!texture.hasLoaded)
355356
{
356-
return;
357+
return false;
357358
}
358359

359360
var gl = this.gl;
@@ -394,7 +395,8 @@ PIXI.WebGLRenderer.prototype.updateTexture = function(texture)
394395

395396
texture._dirty[gl.id] = false;
396397

397-
return texture._glTextures[gl.id];
398+
// return texture._glTextures[gl.id];
399+
return true;
398400

399401
};
400402

src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,11 @@ PIXI.WebGLSpriteBatch.prototype.renderBatch = function(texture, size, startIndex
618618
// check if a texture is dirty..
619619
if (texture._dirty[gl.id])
620620
{
621-
this.renderSession.renderer.updateTexture(texture);
621+
if (!this.renderSession.renderer.updateTexture(texture))
622+
{
623+
// If updateTexture returns false then we cannot render it, so bail out now
624+
return;
625+
}
622626
}
623627
else
624628
{

0 commit comments

Comments
 (0)