Skip to content

Commit 4c3a522

Browse files
committed
Added onFlush and onPostFlush
1 parent ca4168e commit 4c3a522

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/renderer/webgl/WebGLPipeline.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,42 @@ var WebGLPipeline = new Class({
787787
return this;
788788
},
789789

790+
/**
791+
* This method is called every time this pipeline is asked to flush its batch.
792+
*
793+
* It is called immediately before the gl.bufferData and gl.drawArray calls are made, so you can
794+
* perform any final pre-render modifications. To apply changes post-render, see `onPostFlush`.
795+
*
796+
* @method Phaser.Renderer.WebGL.WebGLPipeline#onFlush
797+
* @since 3.0.0
798+
*
799+
* @return {this} This WebGLPipeline instance.
800+
*/
801+
onFlush: function ()
802+
{
803+
return this;
804+
},
805+
806+
/**
807+
* This method is called immediately after this pipeline has finished flushing its batch.
808+
*
809+
* It is called after the `gl.drawArray` call.
810+
*
811+
* You can perform additional post-render effects, but be careful not to call `flush`
812+
* from within this method, or you'll cause an infinite loop.
813+
*
814+
* To apply changes post-render, see `onFlush`.
815+
*
816+
* @method Phaser.Renderer.WebGL.WebGLPipeline#onPostFlush
817+
* @since 3.0.0
818+
*
819+
* @return {this} This WebGLPipeline instance.
820+
*/
821+
onPostFlush: function ()
822+
{
823+
return this;
824+
},
825+
790826
/**
791827
* Uploads the vertex data and emits a draw call for the current batch of vertices.
792828
*
@@ -801,6 +837,8 @@ var WebGLPipeline = new Class({
801837

802838
if (vertexCount > 0)
803839
{
840+
this.onFlush();
841+
804842
var gl = this.gl;
805843
var vertexSize = this.currentShader.vertexSize;
806844

@@ -816,6 +854,8 @@ var WebGLPipeline = new Class({
816854
gl.drawArrays(this.topology, 0, vertexCount);
817855

818856
this.vertexCount = 0;
857+
858+
this.onPostFlush();
819859
}
820860

821861
return this;

0 commit comments

Comments
 (0)