diff --git a/src/renderer/webgl/WebGLPipeline.js b/src/renderer/webgl/WebGLPipeline.js index 403777f44..7f320f973 100644 --- a/src/renderer/webgl/WebGLPipeline.js +++ b/src/renderer/webgl/WebGLPipeline.js @@ -743,6 +743,34 @@ var WebGLPipeline = new Class({ return this; }, + /** + * This method is called every time the Pipeline Manager rebinds this pipeline. + * + * It resets all shaders this pipeline uses, setting their attributes again. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#rebind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + rebind: function () + { + this.renderer.setVertexBuffer(this.vertexBuffer); + + var shaders = this.shaders; + + for (var i = 0; i < shaders.length; i++) + { + shaders[i].rebind(); + } + + this.currentShader = shaders[0]; + + this.onRebind(); + + return this; + }, + /** * TODO * @@ -875,6 +903,20 @@ var WebGLPipeline = new Class({ { }, + /** + * By default this is an empty method hook that you can override and use in your own custom pipelines. + * + * This method is called when the Pipeline Manager needs to rebind this pipeline. This happens after a + * pipeline has been cleared, usually when passing control over to a 3rd party WebGL library, like Spine, + * and then returing to Phaser again. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onRebind + * @since 3.50.0 + */ + onRebind: function () + { + }, + /** * By default this is an empty method hook that you can override and use in your own custom pipelines. * diff --git a/src/renderer/webgl/WebGLShader.js b/src/renderer/webgl/WebGLShader.js index cfb29a568..e2f12c2bd 100644 --- a/src/renderer/webgl/WebGLShader.js +++ b/src/renderer/webgl/WebGLShader.js @@ -235,6 +235,25 @@ var WebGLShader = new Class({ return this; }, + /** + * Sets the program this shader uses as being the active shader in the WebGL Renderer. + * + * Then resets all of the attribute pointers. + * + * @method Phaser.Renderer.WebGL.WebGLShader#rebind + * @since 3.50.0 + * + * @return {this} This WebGLShader instance. + */ + rebind: function () + { + this.renderer.setProgram(this.program); + + this.setAttribPointers(true); + + return this; + }, + /** * Sets the vertex attribute pointers. *