The EXPAND Scale Mode would cause the error "Framebuffer status: Incomplete 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.

This commit is contained in:
Richard Davey 2024-10-10 16:54:46 +01:00
parent c6caba7598
commit 72e2857882

View file

@ -431,12 +431,14 @@ var ScaleManager = new Class({
this.fullscreen = game.device.fullscreen; 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); this.resize(this.width, this.height);
} }
@ -1104,18 +1106,16 @@ var ScaleManager = new Class({
style.width = styleWidth + 'px'; style.width = styleWidth + 'px';
style.height = styleHeight + 'px'; style.height = styleHeight + 'px';
// Expand canvas size to fit game size's width or height // Expand canvas size to fit game size's width or height
var scaleX = this.parentSize.width / baseWidth; var scaleX = this.parentSize.width / baseWidth;
var scaleY = this.parentSize.height / baseHeight; var scaleY = this.parentSize.height / baseHeight;
if (scaleX < scaleY) if (scaleX < scaleY && scaleX !== 0)
{ {
this.baseSize.setSize(baseWidth, this.parentSize.height / scaleX); this.baseSize.setSize(baseWidth, this.parentSize.height / scaleX);
} }
else else if (scaleY !== 0)
{ {
this.baseSize.setSize(this.displaySize.width / scaleY, baseHeight); this.baseSize.setSize(this.displaySize.width / scaleY, baseHeight);
} }