Skip to content

Commit 73524df

Browse files
committed
The Game boot event flow has changed slightly. The Game will now listen for a texturesready event, which is dispatched by the Texture Manager when the default textures have finished processing. Upon receiving this, the Game will emit the ready event, which all the other systems listen for and respond to. The difference is that the Renderer uses the texturesready event to ensure that it is the first thing to be activated, before any other system.
1 parent 94e4411 commit 73524df

4 files changed

Lines changed: 33 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The process of managing scissors in the WebGLRenderer has been completely rewrit
6868
* The `MouseManager` will no longer process its native events if the manager reference has been removed (i.e. you move the pointer as the game is destroying itself)
6969
* The `TouchManager` will no longer process its native events if the manager reference has been removed (i.e. you move the pointer as the game is destroying itself)
7070
* `Particle.color` has been removed as it's now calculated during rendering to allow for Camera alpha support.
71+
* The Game boot event flow has changed slightly. The Game will now listen for a `texturesready` event, which is dispatched by the Texture Manager when the default textures have finished processing. Upon receiving this, the Game will emit the `ready` event, which all the other systems listen for and respond to. The difference is that the Renderer uses the `texturesready` event to ensure that it is the first thing to be activated, before any other system.
7172

7273
### Game Config Resolution Specific Bug Fixes
7374

src/boot/Game.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,26 @@ var Game = new Class({
356356

357357
this.events.emit('boot');
358358

359-
// The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event
360-
this.events.once('ready', this.start, this);
359+
// The Texture Manager has to wait on a couple of non-blocking events before it's fully ready.
360+
// So it will emit this internal event when done:
361+
this.events.once('texturesready', this.texturesReady, this);
362+
},
363+
364+
/**
365+
* Called automatically when the Texture Manager has finished setting up and preparing the
366+
* default textures.
367+
*
368+
* @method Phaser.Game#texturesReady
369+
* @private
370+
* @fires Phaser.Game#ready
371+
* @since 3.12.0
372+
*/
373+
texturesReady: function ()
374+
{
375+
// Start all the other systems
376+
this.events.emit('ready');
377+
378+
this.start();
361379
},
362380

363381
/**

src/renderer/webgl/WebGLRenderer.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ var WebGLRenderer = new Class({
520520

521521
this.resize(this.width, this.height);
522522

523-
this.game.events.once('ready', this.boot, this);
523+
this.game.events.once('texturesready', this.boot, this);
524524

525525
return this;
526526
},
@@ -544,6 +544,8 @@ var WebGLRenderer = new Class({
544544
this.pipelines.TextureTintPipeline.currentFrame = blank;
545545

546546
this.blankTexture = blank;
547+
548+
console.log('renderer boot', this.pipelines.TextureTintPipeline.currentFrame);
547549
},
548550

549551
/**
@@ -965,12 +967,16 @@ var WebGLRenderer = new Class({
965967
* @method Phaser.Renderer.WebGL.WebGLRenderer#setBlankTexture
966968
* @private
967969
* @since 3.12.0
970+
*
971+
* @param {boolean} [force=false] - Force a blank texture set, regardless of what's already bound?
968972
*
969973
* @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer.
970974
*/
971-
setBlankTexture: function ()
975+
setBlankTexture: function (force)
972976
{
973-
if (this.currentActiveTextureUnit !== 0 || !this.currentTextures[0])
977+
if (force === undefined) { force = false; }
978+
979+
if (force || this.currentActiveTextureUnit !== 0 || !this.currentTextures[0])
974980
{
975981
this.setTexture2D(this.blankTexture.glTexture, 0);
976982
}

src/textures/TextureManager.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ var TextureManager = new Class({
116116
* The Boot Handler called by Phaser.Game when it first starts up.
117117
*
118118
* @method Phaser.Textures.TextureManager#boot
119+
* @private
119120
* @since 3.0.0
120121
*/
121122
boot: function ()
@@ -135,6 +136,7 @@ var TextureManager = new Class({
135136
* After 'onload' or 'onerror' invoked twice, emit 'ready' event.
136137
*
137138
* @method Phaser.Textures.TextureManager#updatePending
139+
* @private
138140
* @since 3.0.0
139141
*/
140142
updatePending: function ()
@@ -146,7 +148,7 @@ var TextureManager = new Class({
146148
this.off('onload');
147149
this.off('onerror');
148150

149-
this.game.events.emit('ready');
151+
this.game.events.emit('texturesready');
150152
}
151153
},
152154

0 commit comments

Comments
 (0)