Move WebGL support test into ol.webgl

This commit is contained in:
Tom Payne
2012-10-17 17:25:32 +02:00
parent 1d40b64db1
commit 8cb28a7217
2 changed files with 19 additions and 11 deletions

View File

@@ -19,3 +19,19 @@ ol.webgl.WebGLContextEventType = {
ol.webgl.getContext = function(canvas, opt_attributes) {
return canvas.getContext('experimental-webgl', opt_attributes);
};
/**
* @return {boolean} Is supported.
*/
ol.webgl.isSupported = function() {
if (!('WebGLRenderingContext' in goog.global)) {
return false;
}
try {
var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS);
return !goog.isNull(canvas.getContext('experimental-webgl'));
} catch (e) {
return false;
}
};