Skip to content

Commit

Permalink
feat: change WebGLRenderer.isSupport() to WebGLRenderer.isSupported
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed May 18, 2016
1 parent 6601ffd commit f9f9bc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
31 changes: 9 additions & 22 deletions src/renderer/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{
MAX_BATCH_NUM:2000,
/**
* @language=en
* The num of vertex attribute, readonly.
* The num of vertex attributes, readonly.
* @type {Number}
*/
/**
Expand All @@ -59,15 +59,15 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{
ATTRIBUTE_NUM:5,
/**
* @language=en
* Support WebGL, readonly.
* is WebGL supported, readonly.
* @type {Boolean}
*/
/**
* @language=zh
* 是否支持WebGL。只读属性。
* @type {Boolean}
*/
isSupport:null
isSupported:null
},
renderType:'webgl',
gl:null,
Expand Down Expand Up @@ -132,14 +132,7 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{
}
return false;
},

/**
* @language=en
* @private
* @see Renderer#draw
*/
/**
* @language=zh
* @private
* @see Renderer#draw
*/
Expand Down Expand Up @@ -560,18 +553,12 @@ Shader.prototype = {
}
};

WebGLRenderer.isSupport = function(){
if(this._isSupport !== undefined){
return this._isSupport;
WebGLRenderer.isSupported = (function(){
var canvas = document.createElement('canvas');
if(canvas.getContext && (canvas.getContext('webgl')||canvas.getContext('experimental-webgl'))){
return true;
}
else{
var canvas = document.createElement('canvas');
if(canvas.getContext && (canvas.getContext('webgl')||canvas.getContext('experimental-webgl'))){
this._isSupport = true;
}
else{
this._isSupport = false;
}
return this._isSupport;
return false;
}
};
})();
2 changes: 1 addition & 1 deletion src/view/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ var Stage = Class.create(/** @lends Stage.prototype */{
this.renderer = new DOMRenderer(props);
break;
case 'webgl':
if(WebGLRenderer.isSupport()){
if(WebGLRenderer.isSupported){
this.renderer = new WebGLRenderer(props);
}
else{
Expand Down

0 comments on commit f9f9bc4

Please sign in to comment.