@@ -36,7 +36,7 @@ var TransformMatrix = require('../components/TransformMatrix');
3636 * @extends Phaser.GameObjects.Components.Visible
3737 *
3838 * @param {Phaser.Scene } scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
39- * @param {string } key -
39+ * @param {string } key - The key of the shader to use from the shader cache.
4040 * @param {number } [x=0] - The horizontal position of this Game Object in the world.
4141 * @param {number } [y=0] - The vertical position of this Game Object in the world.
4242 * @param {number } [width=128] - The width of the Game Object.
@@ -523,23 +523,25 @@ var Shader = new Class({
523523 * Called automatically during render.
524524 *
525525 * This method performs matrix ITRS and then stores the resulting value in the `uViewMatrix` uniform.
526- * It then sets up the vertex buffer and shader, updates and syncs the uniforms and finally draws it
527- * to a single quad .
526+ * It then sets up the vertex buffer and shader, updates and syncs the uniforms ready
527+ * for flush to be called .
528528 *
529529 * @method Phaser.GameObjects.Shader#load
530- * @private
531530 * @since 3.17.0
531+ *
532+ * @param {Phaser.GameObjects.Components.TransformMatrix } matrix2D - The transform matrix to use during rendering.
532533 */
533534 load : function ( matrix2D )
534535 {
535536 // ITRS
536537
538+ var width = this . width ;
539+ var height = this . height ;
540+ var renderer = this . renderer ;
537541 var program = this . program ;
538542
539543 var x = - this . _displayOriginX ;
540544 var y = - this . _displayOriginY ;
541- var width = this . width ;
542- var height = this . height ;
543545
544546 var vm = this . viewMatrix ;
545547
@@ -554,25 +556,6 @@ var Shader = new Class({
554556
555557 this . renderer . setMatrix4 ( program , 'uViewMatrix' , false , this . viewMatrix ) ;
556558
557- // Bind
558-
559- var gl = this . gl ;
560- var vertexBuffer = this . vertexBuffer ;
561- var renderer = this . renderer ;
562- var vertexSize = Float32Array . BYTES_PER_ELEMENT * 2 ;
563-
564- renderer . setProgram ( program ) ;
565- renderer . setVertexBuffer ( vertexBuffer ) ;
566-
567- var location = gl . getAttribLocation ( program , 'inPosition' ) ;
568-
569- if ( location !== - 1 )
570- {
571- gl . enableVertexAttribArray ( location ) ;
572-
573- gl . vertexAttribPointer ( location , 2 , gl . FLOAT , false , vertexSize , 0 ) ;
574- }
575-
576559 // Update common uniforms
577560
578561 var uniforms = this . uniforms ;
@@ -597,6 +580,40 @@ var Shader = new Class({
597580 }
598581
599582 this . syncUniforms ( ) ;
583+ } ,
584+
585+ /**
586+ * Called automatically during render.
587+ *
588+ * Sets the active shader, loads the vertex buffer and then draws.
589+ *
590+ * @method Phaser.GameObjects.Shader#flush
591+ * @since 3.17.0
592+ */
593+ flush : function ( )
594+ {
595+ // Bind
596+
597+ var width = this . width ;
598+ var height = this . height ;
599+ var program = this . program ;
600+
601+ var gl = this . gl ;
602+ var vertexBuffer = this . vertexBuffer ;
603+ var renderer = this . renderer ;
604+ var vertexSize = Float32Array . BYTES_PER_ELEMENT * 2 ;
605+
606+ renderer . setProgram ( program ) ;
607+ renderer . setVertexBuffer ( vertexBuffer ) ;
608+
609+ var location = gl . getAttribLocation ( program , 'inPosition' ) ;
610+
611+ if ( location !== - 1 )
612+ {
613+ gl . enableVertexAttribArray ( location ) ;
614+
615+ gl . vertexAttribPointer ( location , 2 , gl . FLOAT , false , vertexSize , 0 ) ;
616+ }
600617
601618 // Draw
602619
@@ -643,12 +660,13 @@ var Shader = new Class({
643660 } ,
644661
645662 /**
646- * Removes all object references in this WebGL Pipeline and removes its program from the WebGL context .
663+ * Internal destroy handler, called as part of the destroy process .
647664 *
648- * @method Phaser.GameObjects.Shader#destroy
649- * @since 3.17.0
665+ * @method Phaser.GameObjects.RenderTexture#preDestroy
666+ * @protected
667+ * @since 3.9.0
650668 */
651- destroy : function ( )
669+ preDestroy : function ( )
652670 {
653671 var gl = this . gl ;
654672
0 commit comments