2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2018-02-01 00:25:33 +00:00
|
|
|
/**
|
|
|
|
* Provides methods used for setting the WebGL rendering pipeline of a Game Object.
|
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Components.Pipeline
|
|
|
|
* @webglOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-29 21:46:48 +00:00
|
|
|
|
|
|
|
var Pipeline = {
|
|
|
|
|
2018-02-01 00:25:33 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Components.Pipeline#defaultPipeline
|
|
|
|
* @type {Phaser.Renderer.WebGL.WebGLPipeline}
|
|
|
|
* @default null
|
|
|
|
* @webglOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-29 21:46:48 +00:00
|
|
|
defaultPipeline: null,
|
2018-02-01 00:25:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Components.Pipeline#pipeline
|
|
|
|
* @type {Phaser.Renderer.WebGL.WebGLPipeline}
|
|
|
|
* @default null
|
|
|
|
* @webglOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-29 21:46:48 +00:00
|
|
|
pipeline: null,
|
|
|
|
|
2018-02-01 00:25:33 +00:00
|
|
|
/**
|
|
|
|
* Sets the initial WebGL Pipeline of this Game Object.
|
|
|
|
* This should only be called during the instantiation of the Game Object.
|
|
|
|
*
|
2018-02-01 01:36:52 +00:00
|
|
|
* @method Phaser.GameObjects.Components.Pipeline#initPipeline
|
2018-02-01 00:25:33 +00:00
|
|
|
* @webglOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} pipelineName - The name of the pipeline to set on this Game Object.
|
|
|
|
*
|
|
|
|
* @return {boolean} `true` if the pipeline was set successfully, otherwise `false`.
|
|
|
|
*/
|
2018-01-29 21:46:48 +00:00
|
|
|
initPipeline: function (pipelineName)
|
|
|
|
{
|
|
|
|
var renderer = this.scene.sys.game.renderer;
|
|
|
|
|
2018-02-28 21:57:32 +00:00
|
|
|
if (renderer && renderer.gl && renderer.hasPipeline(pipelineName))
|
2018-01-29 21:46:48 +00:00
|
|
|
{
|
|
|
|
this.defaultPipeline = renderer.getPipeline(pipelineName);
|
|
|
|
this.pipeline = this.defaultPipeline;
|
2018-02-28 21:57:32 +00:00
|
|
|
|
2018-01-30 03:38:31 +00:00
|
|
|
return true;
|
2018-01-29 21:46:48 +00:00
|
|
|
}
|
|
|
|
|
2018-01-30 03:38:31 +00:00
|
|
|
return false;
|
2018-01-29 21:46:48 +00:00
|
|
|
},
|
|
|
|
|
2018-02-01 00:25:33 +00:00
|
|
|
/**
|
|
|
|
* Sets the active WebGL Pipeline of this Game Object.
|
|
|
|
*
|
2018-02-01 01:36:52 +00:00
|
|
|
* @method Phaser.GameObjects.Components.Pipeline#setPipeline
|
2018-02-01 00:25:33 +00:00
|
|
|
* @webglOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} pipelineName - The name of the pipeline to set on this Game Object.
|
|
|
|
*
|
|
|
|
* @return {boolean} `true` if the pipeline was set successfully, otherwise `false`.
|
|
|
|
*/
|
2018-01-29 21:46:48 +00:00
|
|
|
setPipeline: function (pipelineName)
|
|
|
|
{
|
|
|
|
var renderer = this.scene.sys.game.renderer;
|
|
|
|
|
2018-02-28 21:57:32 +00:00
|
|
|
if (renderer && renderer.gl && renderer.hasPipeline(pipelineName))
|
2018-01-29 21:46:48 +00:00
|
|
|
{
|
|
|
|
this.pipeline = renderer.getPipeline(pipelineName);
|
2018-02-28 21:57:32 +00:00
|
|
|
|
2018-01-30 03:38:31 +00:00
|
|
|
return true;
|
2018-01-29 21:46:48 +00:00
|
|
|
}
|
|
|
|
|
2018-01-30 03:38:31 +00:00
|
|
|
return false;
|
2018-01-29 21:46:48 +00:00
|
|
|
},
|
|
|
|
|
2018-02-01 00:25:33 +00:00
|
|
|
/**
|
|
|
|
* Resets the WebGL Pipeline of this Game Object back to the default it was created with.
|
|
|
|
*
|
2018-02-01 01:36:52 +00:00
|
|
|
* @method Phaser.GameObjects.Components.Pipeline#resetPipeline
|
2018-02-01 00:25:33 +00:00
|
|
|
* @webglOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} `true` if the pipeline was set successfully, otherwise `false`.
|
|
|
|
*/
|
2018-01-29 21:46:48 +00:00
|
|
|
resetPipeline: function ()
|
|
|
|
{
|
|
|
|
this.pipeline = this.defaultPipeline;
|
2018-02-28 21:57:32 +00:00
|
|
|
|
2018-01-30 03:38:31 +00:00
|
|
|
return (this.pipeline !== null);
|
2018-01-30 22:46:43 +00:00
|
|
|
},
|
|
|
|
|
2018-02-01 00:25:33 +00:00
|
|
|
/**
|
|
|
|
* Gets the name of the WebGL Pipeline this Game Object is currently using.
|
|
|
|
*
|
2018-02-01 01:36:52 +00:00
|
|
|
* @method Phaser.GameObjects.Components.Pipeline#getPipelineName
|
2018-02-01 00:25:33 +00:00
|
|
|
* @webglOnly
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {string} The string-based name of the pipeline being used by this Game Object.
|
|
|
|
*/
|
2018-01-30 22:46:43 +00:00
|
|
|
getPipelineName: function ()
|
|
|
|
{
|
|
|
|
return this.pipeline.name;
|
2018-01-29 21:46:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Pipeline;
|