|
7 | 7 |
|
8 | 8 | var Class = require('../../utils/Class'); |
9 | 9 | var DeepCopy = require('../../utils/object/DeepCopy'); |
| 10 | +var Events = require('./events'); |
10 | 11 | var GetFastValue = require('../../utils/object/GetFastValue'); |
11 | 12 | var Matrix4 = require('../../math/Matrix4'); |
12 | 13 | var RenderTarget = require('./RenderTarget'); |
@@ -259,6 +260,16 @@ var WebGLPipeline = new Class({ |
259 | 260 | */ |
260 | 261 | this.hasBooted = false; |
261 | 262 |
|
| 263 | + /** |
| 264 | + * Indicates if this is a Post FX Pipeline, or not. |
| 265 | + * |
| 266 | + * @name Phaser.Renderer.WebGL.WebGLPipeline#isPostFX |
| 267 | + * @type {boolean} |
| 268 | + * @readonly |
| 269 | + * @since 3.50.0 |
| 270 | + */ |
| 271 | + this.isPostFX = false; |
| 272 | + |
262 | 273 | /** |
263 | 274 | * An array of RenderTarget instances that belong to this pipeline. |
264 | 275 | * |
@@ -311,7 +322,7 @@ var WebGLPipeline = new Class({ |
311 | 322 | * @type {Phaser.Math.Matrix4} |
312 | 323 | * @since 3.50.0 |
313 | 324 | */ |
314 | | - this.projectionMatrix = new Matrix4().identity(); |
| 325 | + this.projectionMatrix; |
315 | 326 |
|
316 | 327 | /** |
317 | 328 | * The configuration object that was used to create this pipeline. |
@@ -343,6 +354,11 @@ var WebGLPipeline = new Class({ |
343 | 354 | var config = this.config; |
344 | 355 | var renderer = this.renderer; |
345 | 356 |
|
| 357 | + if (!this.isPostFX) |
| 358 | + { |
| 359 | + this.projectionMatrix = new Matrix4().identity(); |
| 360 | + } |
| 361 | + |
346 | 362 | // Create the Render Targets |
347 | 363 |
|
348 | 364 | var renderTargets = this.renderTargets; |
@@ -438,6 +454,11 @@ var WebGLPipeline = new Class({ |
438 | 454 |
|
439 | 455 | this.hasBooted = true; |
440 | 456 |
|
| 457 | + renderer.on(Events.RESIZE, this.resize, this); |
| 458 | + renderer.on(Events.PRE_RENDER, this.onPreRender, this); |
| 459 | + renderer.on(Events.RENDER, this.onRender, this); |
| 460 | + renderer.on(Events.POST_RENDER, this.onPostRender, this); |
| 461 | + |
441 | 462 | this.onBoot(); |
442 | 463 | }, |
443 | 464 |
|
@@ -469,29 +490,6 @@ var WebGLPipeline = new Class({ |
469 | 490 | { |
470 | 491 | }, |
471 | 492 |
|
472 | | - /** |
473 | | - * Creates a brand new WebGLPipeline instance based on the configuration object that |
474 | | - * was used to create this one. |
475 | | - * |
476 | | - * The new instance is returned by this method. Note that the new instance is _not_ |
477 | | - * added to the Pipeline Manager. You will need to add it yourself should you require so. |
478 | | - * |
479 | | - * @method Phaser.Renderer.WebGL.WebGLPipeline#mvpInit |
480 | | - * @since 3.50.0 |
481 | | - * |
482 | | - * @param {string} name - The new name to give the cloned pipeline. |
483 | | - * |
484 | | - * @return {Phaser.Renderer.WebGL.WebGLPipeline} A clone of this WebGLPipeline instance. |
485 | | - */ |
486 | | - clone: function (name) |
487 | | - { |
488 | | - var clone = new WebGLPipeline(this.config); |
489 | | - |
490 | | - clone.name = name; |
491 | | - |
492 | | - return clone; |
493 | | - }, |
494 | | - |
495 | 493 | /** |
496 | 494 | * Sets the currently active shader within this pipeline. |
497 | 495 | * |
@@ -695,7 +693,11 @@ var WebGLPipeline = new Class({ |
695 | 693 |
|
696 | 694 | var projectionMatrix = this.projectionMatrix; |
697 | 695 |
|
698 | | - projectionMatrix.ortho(0, width, height, 0, -1000, 1000); |
| 696 | + // Because Post FX Pipelines don't have them |
| 697 | + if (projectionMatrix) |
| 698 | + { |
| 699 | + projectionMatrix.ortho(0, width, height, 0, -1000, 1000); |
| 700 | + } |
699 | 701 |
|
700 | 702 | var i; |
701 | 703 |
|
@@ -1143,7 +1145,7 @@ var WebGLPipeline = new Class({ |
1143 | 1145 | { |
1144 | 1146 | if (unit === undefined) { unit = this.currentUnit; } |
1145 | 1147 |
|
1146 | | - var postPipeline = (gameObject && gameObject.postPipeline); |
| 1148 | + var postPipeline = (gameObject && gameObject.hasPostPipeline); |
1147 | 1149 |
|
1148 | 1150 | if (postPipeline) |
1149 | 1151 | { |
@@ -1857,6 +1859,13 @@ var WebGLPipeline = new Class({ |
1857 | 1859 |
|
1858 | 1860 | this.gl.deleteBuffer(this.vertexBuffer); |
1859 | 1861 |
|
| 1862 | + var renderer = this.renderer; |
| 1863 | + |
| 1864 | + renderer.off(Events.RESIZE, this.resize, this); |
| 1865 | + renderer.off(Events.PRE_RENDER, this.onPreRender, this); |
| 1866 | + renderer.off(Events.RENDER, this.onRender, this); |
| 1867 | + renderer.off(Events.POST_RENDER, this.onPostRender, this); |
| 1868 | + |
1860 | 1869 | this.game = null; |
1861 | 1870 | this.renderer = null; |
1862 | 1871 | this.gl = null; |
|
0 commit comments