mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
PIXI.WebGLRenderer.destroy has been fixed to decrement the glContextId
and remove it from the PIXI.instances global. Game.destroy
now hooks into this. This now means that you can now delete and create your Phaser game over and over without it crashing WebGL after the 4th attempt (#1260)
This commit is contained in:
parent
b68c3071a6
commit
8892f46a83
3 changed files with 8 additions and 27 deletions
|
@ -151,6 +151,7 @@ Thanks to @pnstickne for vast majority of this update.
|
||||||
* Pointer.stop would call `event.preventDefault` if `Pointer._stateReset` was `true`, which is always `true` after a State has changed and before Pointer.start has been called. However this broken interacting with DOM elements in the case where the State changes and you immediately try to use the DOM element without first having clicked on the Phaser game. An additional guard was added so `preventDefault` will now only be called if both `_stateReste` and `Pointer.withinGame` are true (thanks @satan6 #1509)
|
* Pointer.stop would call `event.preventDefault` if `Pointer._stateReset` was `true`, which is always `true` after a State has changed and before Pointer.start has been called. However this broken interacting with DOM elements in the case where the State changes and you immediately try to use the DOM element without first having clicked on the Phaser game. An additional guard was added so `preventDefault` will now only be called if both `_stateReste` and `Pointer.withinGame` are true (thanks @satan6 #1509)
|
||||||
* Group.forEach (and many other Group methods) now uses the `children.length` value directly instead of caching it, which both helps performance and stops the loop from breaking should you remove a Group child in the invoked callback.
|
* Group.forEach (and many other Group methods) now uses the `children.length` value directly instead of caching it, which both helps performance and stops the loop from breaking should you remove a Group child in the invoked callback.
|
||||||
* Phaser.Ellipse.contains is now working again (thanks @spayton)
|
* Phaser.Ellipse.contains is now working again (thanks @spayton)
|
||||||
|
* PIXI.WebGLRenderer.destroy has been fixed to decrement the `glContextId` and remove it from the PIXI.instances global. `Game.destroy` now hooks into this. This now means that you can now delete and create your Phaser game over and over without it crashing WebGL after the 4th attempt (#1260)
|
||||||
|
|
||||||
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
|
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
|
||||||
|
|
||||||
|
|
|
@ -956,31 +956,8 @@ Phaser.Game.prototype = {
|
||||||
this.world = null;
|
this.world = null;
|
||||||
this.isBooted = false;
|
this.isBooted = false;
|
||||||
|
|
||||||
if (this.renderType === Phaser.WEBGL)
|
this.renderer.destroy(false);
|
||||||
{
|
Phaser.Canvas.removeFromDOM(this.canvas);
|
||||||
PIXI.glContexts[this.renderer.glContextId] = null;
|
|
||||||
|
|
||||||
this.renderer.projection = null;
|
|
||||||
this.renderer.offset = null;
|
|
||||||
|
|
||||||
this.renderer.shaderManager.destroy();
|
|
||||||
this.renderer.spriteBatch.destroy();
|
|
||||||
this.renderer.maskManager.destroy();
|
|
||||||
this.renderer.filterManager.destroy();
|
|
||||||
|
|
||||||
this.renderer.shaderManager = null;
|
|
||||||
this.renderer.spriteBatch = null;
|
|
||||||
this.renderer.maskManager = null;
|
|
||||||
this.renderer.filterManager = null;
|
|
||||||
|
|
||||||
this.renderer.gl = null;
|
|
||||||
this.renderer.renderSession = null;
|
|
||||||
Phaser.Canvas.removeFromDOM(this.canvas);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.renderer.destroy(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Phaser.GAMES[this.id] = null;
|
Phaser.GAMES[this.id] = null;
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ PIXI.WebGLRenderer.prototype.initContext = function()
|
||||||
throw new Error('This browser does not support webGL. Try using the canvas renderer');
|
throw new Error('This browser does not support webGL. Try using the canvas renderer');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.glContextId = gl.id = PIXI.WebGLRenderer.glContextId ++;
|
this.glContextId = gl.id = PIXI.WebGLRenderer.glContextId++;
|
||||||
|
|
||||||
PIXI.glContexts[this.glContextId] = gl;
|
PIXI.glContexts[this.glContextId] = gl;
|
||||||
|
|
||||||
|
@ -502,7 +502,6 @@ PIXI.WebGLRenderer.prototype.destroy = function()
|
||||||
this.projection = null;
|
this.projection = null;
|
||||||
this.offset = null;
|
this.offset = null;
|
||||||
|
|
||||||
// time to create the render managers! each one focuses on managine a state in webGL
|
|
||||||
this.shaderManager.destroy();
|
this.shaderManager.destroy();
|
||||||
this.spriteBatch.destroy();
|
this.spriteBatch.destroy();
|
||||||
this.maskManager.destroy();
|
this.maskManager.destroy();
|
||||||
|
@ -515,6 +514,10 @@ PIXI.WebGLRenderer.prototype.destroy = function()
|
||||||
|
|
||||||
this.gl = null;
|
this.gl = null;
|
||||||
this.renderSession = null;
|
this.renderSession = null;
|
||||||
|
|
||||||
|
PIXI.instances[this.glContextId] = null;
|
||||||
|
|
||||||
|
PIXI.WebGLRenderer.glContextId--;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue