Skip to content

Commit 6aef375

Browse files
committed
WebGLRenderer.previousPipeline is a new property that is set during a call to clearPipeline and used during calls to rebindPipeline, allowing the renderer to rebind any previous pipeline, not just the Multi Pipeline.
The `WebGLRenderer.rebindPipeline` method has been changed slightly. Previously, you had to specify the `pipelineInstance`, but this is now optional. If you don't, it will use the new `previousPipeline` property instead. If not set, or none given, it will now return without throwing gl errors as well.
1 parent 4fef74a commit 6aef375

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

src/renderer/webgl/WebGLRenderer.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ var WebGLRenderer = new Class({
274274
this.normalTexture;
275275

276276
/**
277-
* Current framebuffer in use
277+
* Current framebuffer in use.
278278
*
279279
* @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer
280280
* @type {WebGLFramebuffer}
@@ -284,7 +284,7 @@ var WebGLRenderer = new Class({
284284
this.currentFramebuffer = null;
285285

286286
/**
287-
* Current WebGLPipeline in use
287+
* Current WebGLPipeline in use.
288288
*
289289
* @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline
290290
* @type {Phaser.Renderer.WebGL.WebGLPipeline}
@@ -294,7 +294,18 @@ var WebGLRenderer = new Class({
294294
this.currentPipeline = null;
295295

296296
/**
297-
* Current WebGLProgram in use
297+
* The previous WebGLPipeline in use.
298+
* This is set when `clearPipeline` is called and restored in `rebindPipeline` if none is given.
299+
*
300+
* @name Phaser.Renderer.WebGL.WebGLRenderer#previousPipeline
301+
* @type {Phaser.Renderer.WebGL.WebGLPipeline}
302+
* @default null
303+
* @since 3.50.0
304+
*/
305+
this.previousPipeline = null;
306+
307+
/**
308+
* Current WebGLProgram in use.
298309
*
299310
* @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram
300311
* @type {WebGLProgram}
@@ -1206,10 +1217,20 @@ var WebGLRenderer = new Class({
12061217
* @method Phaser.Renderer.WebGL.WebGLRenderer#rebindPipeline
12071218
* @since 3.16.0
12081219
*
1209-
* @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - The pipeline instance to be activated.
1220+
* @param {Phaser.Renderer.WebGL.WebGLPipeline} [pipelineInstance] - The pipeline instance to be activated.
12101221
*/
12111222
rebindPipeline: function (pipelineInstance)
12121223
{
1224+
if (pipelineInstance === undefined && this.previousPipeline)
1225+
{
1226+
pipelineInstance = this.previousPipeline;
1227+
}
1228+
1229+
if (!pipelineInstance)
1230+
{
1231+
return;
1232+
}
1233+
12131234
var gl = this.gl;
12141235

12151236
gl.disable(gl.DEPTH_TEST);
@@ -1254,6 +1275,8 @@ var WebGLRenderer = new Class({
12541275
{
12551276
this.flush();
12561277

1278+
this.previousPipeline = this.currentPipeline;
1279+
12571280
this.currentPipeline = null;
12581281
this.currentProgram = null;
12591282
this.currentVertexBuffer = null;

0 commit comments

Comments
 (0)