From 14ecb18a9c0cd72753194b6a17f5c91a4483d5a3 Mon Sep 17 00:00:00 2001 From: ChiaNing Date: Wed, 15 Jan 2020 14:24:57 +0800 Subject: [PATCH] hack splash canvas for CocosPlay (#6107) --- cocos/core/splash-screen-webgl.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cocos/core/splash-screen-webgl.ts b/cocos/core/splash-screen-webgl.ts index d6a98ab56d..1d4c35fc15 100644 --- a/cocos/core/splash-screen-webgl.ts +++ b/cocos/core/splash-screen-webgl.ts @@ -219,6 +219,14 @@ export class SplashScreenWebgl { } private initMatrix () { + // TODO: hack for cocosPlay cause on landscape canvas value is wrong + if (CC_COCOSPLAY && window._CCSettings.orientation === 'landscape' && this.gl.canvas.width < this.gl.canvas.height ) { + let width = this.gl.canvas.height; + let height = this.gl.canvas.width; + this.gl.canvas.width = width; + this.gl.canvas.height = height; + } + const screenWidth = this.gl.canvas.width; const screenHeight = this.gl.canvas.height; const displayRatio = this.setting.displayRatio; @@ -334,12 +342,20 @@ export class SplashScreenWebgl { const elapsedTime = time - this.startTime; const precent = clamp01(elapsedTime / this.setting.totalTime); const alpha = easing.cubicOut(precent); - + gl.enable(gl.BLEND); gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); - + gl.bindFramebuffer(gl.FRAMEBUFFER, null); - + + // TODO: hack for cocosPlay cause on landscape canvas value is wrong + if (CC_COCOSPLAY && window._CCSettings.orientation === 'landscape' && this.gl.canvas.width < this.gl.canvas.height ) { + let width = this.gl.canvas.height; + let height = this.gl.canvas.width; + this.gl.canvas.width = width; + this.gl.canvas.height = height; + } + gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); gl.clearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);