fallback GL if actually unavailable (#4192)

This commit is contained in:
Yun Hsiao Wu
2019-04-11 12:31:07 +08:00
committed by Weiliang Wang
parent ae96a971d8
commit e77f4d415e
2 changed files with 16 additions and 12 deletions
+7 -6
View File
@@ -160,12 +160,6 @@ class Director extends EventTarget {
init () {
this._root = new Root(cc.game._gfxDevice);
let rootInfo = {};
if(!this._root.initialize(rootInfo)) {
return false;
}
this._totalFrames = 0;
this._lastUpdate = performance.now();
this._paused = false;
@@ -180,6 +174,13 @@ class Director extends EventTarget {
}
this.sharedInit();
this._root = new Root(cc.game._gfxDevice);
let rootInfo = {};
if(!this._root.initialize(rootInfo)) {
return false;
}
return true;
}
+9 -6
View File
@@ -699,15 +699,18 @@ class Game extends EventTarget {
this._gfxDevice = new cc.WebGLGFXDevice();
}
let nativeWidth = Math.floor(screen.width * cc.view._devicePixelRatio);
let nativeHeight = Math.floor(screen.height * cc.view._devicePixelRatio);
this._gfxDevice.initialize({
const opts = {
canvasElm: localCanvas,
debug: true,
devicePixelRatio: window.devicePixelRatio,
nativeWidth,
nativeHeight,
});
nativeWidth: Math.floor(screen.width * cc.view._devicePixelRatio),
nativeHeight: Math.floor(screen.height * cc.view._devicePixelRatio),
};
// fallback if WebGL2 is actually unavailable
if (!this._gfxDevice.initialize(opts) && useWebGL2) {
this._gfxDevice = new cc.WebGLGFXDevice();
this._gfxDevice.initialize(opts);
}
}
if (!this._gfxDevice) {