Skip to content

Commit

Permalink
The EXPAND Scale Mode would cause the error "Framebuffer status: In…
Browse files Browse the repository at this point in the history
…complete Attachment" under WebGL if the Phaser game loaded into an iframe or element with a size of 0 on either axis, such as when you load the game into a 0x0 iframe before expanding it. It now protects against divide by zero errors.
  • Loading branch information
photonstorm committed Oct 10, 2024
1 parent c6caba7 commit 72e2857
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/scale/ScaleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,14 @@ var ScaleManager = new Class({

this.fullscreen = game.device.fullscreen;

if ((this.scaleMode !== CONST.SCALE_MODE.RESIZE) && (this.scaleMode !== CONST.SCALE_MODE.EXPAND))
var scaleMode = this.scaleMode;

if (scaleMode !== CONST.SCALE_MODE.RESIZE && scaleMode !== CONST.SCALE_MODE.EXPAND)
{
this.displaySize.setAspectMode(this.scaleMode);
this.displaySize.setAspectMode(scaleMode);
}

if (this.scaleMode === CONST.SCALE_MODE.NONE)
if (scaleMode === CONST.SCALE_MODE.NONE)
{
this.resize(this.width, this.height);
}
Expand Down Expand Up @@ -1104,18 +1106,16 @@ var ScaleManager = new Class({
style.width = styleWidth + 'px';
style.height = styleHeight + 'px';


// Expand canvas size to fit game size's width or height

var scaleX = this.parentSize.width / baseWidth;

var scaleY = this.parentSize.height / baseHeight;

if (scaleX < scaleY)
if (scaleX < scaleY && scaleX !== 0)
{
this.baseSize.setSize(baseWidth, this.parentSize.height / scaleX);
}
else
else if (scaleY !== 0)
{
this.baseSize.setSize(this.displaySize.width / scaleY, baseHeight);
}
Expand Down

0 comments on commit 72e2857

Please sign in to comment.