mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
using landscape layout to device initialization
This commit is contained in:
+14
-2
@@ -699,8 +699,20 @@ class Game extends EventTarget {
|
||||
this._gfxDevice = new cc.WebGLGFXDevice();
|
||||
}
|
||||
|
||||
const nativeWidth = Math.floor(screen.width * window.devicePixelRatio);
|
||||
const nativeHeight = Math.floor(screen.height * window.devicePixelRatio);
|
||||
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
|
||||
cc.view._initFrameSize();
|
||||
let nativeWidth = Math.floor(screen.width * window.devicePixelRatio);
|
||||
let nativeHeight = Math.floor(screen.height * window.devicePixelRatio);
|
||||
|
||||
if (nativeHeight > nativeWidth) {
|
||||
let temp = localCanvas.width;
|
||||
localCanvas.width = localCanvas.height;
|
||||
localCanvas.height = temp;
|
||||
|
||||
temp = nativeWidth;
|
||||
nativeWidth = nativeHeight;
|
||||
nativeHeight = temp;
|
||||
}
|
||||
|
||||
this._gfxDevice.initialize({
|
||||
canvasElm: localCanvas,
|
||||
|
||||
@@ -1097,12 +1097,15 @@ class ContainerStrategy {
|
||||
locContainer.style.height = locCanvas.style.height = h + 'px';
|
||||
}
|
||||
// Setup pixel ratio for retina display
|
||||
/*
|
||||
var devicePixelRatio = view._devicePixelRatio = 1;
|
||||
if (view.isRetinaEnabled())
|
||||
devicePixelRatio = view._devicePixelRatio = Math.min(2, window.devicePixelRatio || 1);
|
||||
|
||||
// Setup canvas
|
||||
// locCanvas.width = w * devicePixelRatio;
|
||||
// locCanvas.height = h * devicePixelRatio;
|
||||
locCanvas.width = w * devicePixelRatio;
|
||||
locCanvas.height = h * devicePixelRatio;
|
||||
*/
|
||||
|
||||
locCanvas.width = w;
|
||||
locCanvas.height = h;
|
||||
|
||||
Reference in New Issue
Block a user