Skip to content

Commit 240914e

Browse files
committed
Fixed some types and removed resize calls
1 parent 7144f64 commit 240914e

2 files changed

Lines changed: 31 additions & 18 deletions

File tree

src/renderer/canvas/CanvasRenderer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ var CanvasRenderer = new Class({
245245
*/
246246
resize: function (width, height)
247247
{
248+
this.width = width;
249+
this.height = height;
250+
251+
/*
248252
var resolution = this.config.resolution;
249253
250254
this.width = width * resolution;
@@ -258,6 +262,7 @@ var CanvasRenderer = new Class({
258262
this.gameCanvas.style.width = (this.width / resolution) + 'px';
259263
this.gameCanvas.style.height = (this.height / resolution) + 'px';
260264
}
265+
*/
261266

262267
// Resizing a canvas will reset imageSmoothingEnabled (and probably other properties)
263268
if (this.scaleMode === ScaleModes.NEAREST)

src/renderer/webgl/WebGLRenderer.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,22 @@ var WebGLRenderer = new Class({
112112
this.type = CONST.WEBGL;
113113

114114
/**
115-
* The width of a rendered frame.
115+
* The width of the canvas being rendered to.
116116
*
117117
* @name Phaser.Renderer.WebGL.WebGLRenderer#width
118-
* @type {number}
118+
* @type {integer}
119119
* @since 3.0.0
120120
*/
121-
this.width = game.config.width;
121+
this.width = game.scale.canvasWidth;
122122

123123
/**
124-
* The height of a rendered frame.
124+
* The height of the canvas being rendered to.
125125
*
126126
* @name Phaser.Renderer.WebGL.WebGLRenderer#height
127-
* @type {number}
127+
* @type {integer}
128128
* @since 3.0.0
129129
*/
130-
this.height = game.config.height;
130+
this.height = game.scale.canvasHeight;
131131

132132
/**
133133
* The canvas which this WebGL Renderer draws to.
@@ -567,7 +567,24 @@ var WebGLRenderer = new Class({
567567

568568
this.setBlendMode(CONST.BlendModes.NORMAL);
569569

570-
this.resize(this.width, this.height);
570+
var width = this.width;
571+
var height = this.height;
572+
573+
gl.viewport(0, 0, width, height);
574+
575+
var pipelines = this.pipelines;
576+
577+
// Update all registered pipelines
578+
for (var pipelineName in pipelines)
579+
{
580+
pipelines[pipelineName].resize(width, height, this.game.scale.resolution);
581+
}
582+
583+
this.drawingBufferHeight = gl.drawingBufferHeight;
584+
585+
this.defaultCamera.setSize(width, height);
586+
587+
gl.scissor(0, (this.drawingBufferHeight - height), width, height);
571588

572589
this.game.events.once('texturesready', this.boot, this);
573590

@@ -596,7 +613,7 @@ var WebGLRenderer = new Class({
596613
},
597614

598615
/**
599-
* Resizes the internal canvas and drawing buffer.
616+
* Resizes the drawing buffer.
600617
*
601618
* @method Phaser.Renderer.WebGL.WebGLRenderer#resize
602619
* @since 3.0.0
@@ -610,20 +627,11 @@ var WebGLRenderer = new Class({
610627
{
611628
var gl = this.gl;
612629
var pipelines = this.pipelines;
613-
var resolution = this.config.resolution;
630+
var resolution = this.game.scale.resolution;
614631

615632
this.width = Math.floor(width * resolution);
616633
this.height = Math.floor(height * resolution);
617634

618-
this.canvas.width = this.width;
619-
this.canvas.height = this.height;
620-
621-
if (this.config.autoResize)
622-
{
623-
this.canvas.style.width = (this.width / resolution) + 'px';
624-
this.canvas.style.height = (this.height / resolution) + 'px';
625-
}
626-
627635
gl.viewport(0, 0, this.width, this.height);
628636

629637
// Update all registered pipelines

0 commit comments

Comments
 (0)