@@ -84,7 +84,6 @@ var WebGLRenderer = new Class({
8484 backgroundColor : gameConfig . backgroundColor ,
8585 contextCreation : contextCreationConfig ,
8686 resolution : gameConfig . resolution ,
87- autoResize : gameConfig . autoResize ,
8887 roundPixels : gameConfig . roundPixels ,
8988 maxTextures : gameConfig . maxTextures ,
9089 maxTextureSize : gameConfig . maxTextureSize ,
@@ -110,14 +109,23 @@ var WebGLRenderer = new Class({
110109 */
111110 this . type = CONST . WEBGL ;
112111
112+ /**
113+ * The core Scale Manager.
114+ *
115+ * @name Phaser.Renderer.WebGL.WebGLRenderer#scaleManager
116+ * @type {Phaser.DOM.ScaleManager }
117+ * @since 3.16.0
118+ */
119+ this . scaleManager = game . scale ;
120+
113121 /**
114122 * The width of the canvas being rendered to.
115123 *
116124 * @name Phaser.Renderer.WebGL.WebGLRenderer#width
117125 * @type {integer }
118126 * @since 3.0.0
119127 */
120- this . width = game . scale . gameSize . width ;
128+ this . width = this . scaleManager . baseSize . width ;
121129
122130 /**
123131 * The height of the canvas being rendered to.
@@ -126,7 +134,7 @@ var WebGLRenderer = new Class({
126134 * @type {integer }
127135 * @since 3.0.0
128136 */
129- this . height = game . scale . gameSize . height ;
137+ this . height = this . scaleManager . baseSize . height ;
130138
131139 /**
132140 * The canvas which this WebGL Renderer draws to.
@@ -421,6 +429,13 @@ var WebGLRenderer = new Class({
421429 */
422430 this . blankTexture = null ;
423431
432+ /**
433+ * A default Camera used in calls when no other camera has been provided.
434+ *
435+ * @name Phaser.Renderer.WebGL.WebGLRenderer#defaultCamera
436+ * @type {Phaser.Cameras.Scene2D.BaseCamera }
437+ * @since 3.12.0
438+ */
424439 this . defaultCamera = new BaseCamera ( 0 , 0 , 0 , 0 ) ;
425440
426441 /**
@@ -467,8 +482,7 @@ var WebGLRenderer = new Class({
467482 } ,
468483
469484 /**
470- * Creates a new WebGLRenderingContext and initializes all internal
471- * state.
485+ * Creates a new WebGLRenderingContext and initializes all internal state.
472486 *
473487 * @method Phaser.Renderer.WebGL.WebGLRenderer#init
474488 * @since 3.0.0
@@ -573,24 +587,7 @@ var WebGLRenderer = new Class({
573587
574588 this . setBlendMode ( CONST . BlendModes . NORMAL ) ;
575589
576- var width = this . width ;
577- var height = this . height ;
578-
579- gl . viewport ( 0 , 0 , width , height ) ;
580-
581- var pipelines = this . pipelines ;
582-
583- // Update all registered pipelines
584- for ( var pipelineName in pipelines )
585- {
586- pipelines [ pipelineName ] . resize ( width , height , this . game . scale . resolution ) ;
587- }
588-
589- this . drawingBufferHeight = gl . drawingBufferHeight ;
590-
591- this . defaultCamera . setSize ( width , height ) ;
592-
593- gl . scissor ( 0 , ( this . drawingBufferHeight - height ) , width , height ) ;
590+ this . resize ( ) ;
594591
595592 this . game . events . once ( 'texturesready' , this . boot , this ) ;
596593
@@ -627,26 +624,30 @@ var WebGLRenderer = new Class({
627624 } ,
628625
629626 /**
630- * Resizes the drawing buffer.
627+ * Resizes the drawing buffer to match that required by the Scale Manager .
631628 *
632629 * @method Phaser.Renderer.WebGL.WebGLRenderer#resize
633630 * @since 3.0.0
634631 *
635- * @param {number } width - The width of the renderer.
636- * @param {number } height - The height of the renderer.
632+ * @param {number } [width] - The new width of the renderer. If not specified it uses the base size from the Scale Manager.
633+ * @param {number } [height] - The new height of the renderer. If not specified it uses the base size from the Scale Manager.
634+ * @param {number } [resolution] - The new resolution of the renderer. If not specified it uses the resolution from the Scale Manager.
637635 *
638636 * @return {this } This WebGLRenderer instance.
639637 */
640- resize : function ( width , height )
638+ resize : function ( width , height , resolution )
641639 {
640+ if ( width === undefined ) { width = this . scaleManager . baseSize . width ; }
641+ if ( height === undefined ) { height = this . scaleManager . baseSize . height ; }
642+ if ( resolution === undefined ) { resolution = this . scaleManager . resolution ; }
643+
642644 var gl = this . gl ;
643645 var pipelines = this . pipelines ;
644- var resolution = this . game . scale . resolution ;
645646
646- this . width = Math . floor ( width * resolution ) ;
647- this . height = Math . floor ( height * resolution ) ;
647+ this . width = width ;
648+ this . height = height ;
648649
649- gl . viewport ( 0 , 0 , this . width , this . height ) ;
650+ gl . viewport ( 0 , 0 , width , height ) ;
650651
651652 // Update all registered pipelines
652653 for ( var pipelineName in pipelines )
@@ -656,9 +657,9 @@ var WebGLRenderer = new Class({
656657
657658 this . drawingBufferHeight = gl . drawingBufferHeight ;
658659
659- this . defaultCamera . setSize ( width , height ) ;
660+ gl . scissor ( 0 , ( gl . drawingBufferHeight - height ) , width , height ) ;
660661
661- gl . scissor ( 0 , ( this . drawingBufferHeight - this . height ) , this . width , this . height ) ;
662+ this . defaultCamera . setSize ( width , height ) ;
662663
663664 return this ;
664665 } ,
0 commit comments