Skip to content

Commit 37638e4

Browse files
committed
Improve webgl compatibility
1 parent ca0a6ae commit 37638e4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CCBoot.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ cc.loader = (function () {
916916

917917
var self = this;
918918
var errorCallback = function () {
919+
this.removeEventListener('load', loadCallback, false);
919920
this.removeEventListener('error', errorCallback, false);
920921

921922
if (img.crossOrigin && img.crossOrigin.toLowerCase() === "anonymous") {
@@ -1757,7 +1758,7 @@ var _initSys = function () {
17571758
sys.browserVersion = "";
17581759
/* Determine the browser version number */
17591760
(function(){
1760-
var versionReg1 = /(micromessenger|qq|mx|maxthon|baidu|sogou)(mobile)?(browser)?\/?([\d.]+)/i;
1761+
var versionReg1 = /(micromessenger|mqqbrowser|qq|maxthon|baidu|sogou)(mobile)?(browser)?\/?([\d.]+)/i;
17611762
var versionReg2 = /(msie |rv:|firefox|chrome|ucbrowser|oupeng|opera|opr|safari|miui)(mobile)?(browser)?\/?([\d.]+)/i;
17621763
var tmp = ua.match(versionReg1);
17631764
if(!tmp) tmp = ua.match(versionReg2);
@@ -1844,7 +1845,7 @@ var _initSys = function () {
18441845
var tmpCanvas = document.createElement("CANVAS");
18451846
try{
18461847
var context = cc.create3DContext(tmpCanvas);
1847-
if (context && context.getShaderPrecisionFormat) {
1848+
if (context) {
18481849
_supportWebGL = true;
18491850
}
18501851

cocos2d/shaders/CCGLProgram.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,8 @@ cc.GLProgram.create = function (vShaderFileName, fShaderFileName) {
795795
cc.GLProgram._highpSupported = null;
796796

797797
cc.GLProgram._isHighpSupported = function () {
798-
if (cc.GLProgram._highpSupported == null) {
799-
var ctx = cc._renderContext;
798+
var ctx = cc._renderContext;
799+
if (ctx.getShaderPrecisionFormat && cc.GLProgram._highpSupported == null) {
800800
var highp = ctx.getShaderPrecisionFormat(ctx.FRAGMENT_SHADER, ctx.HIGH_FLOAT);
801801
cc.GLProgram._highpSupported = highp.precision !== 0;
802802
}

0 commit comments

Comments
 (0)