Add WebGL support test.

This commit is contained in:
Thibaut Despoulain
2014-03-29 14:51:17 -07:00
parent 0d87df96db
commit 92833cec7c
2 changed files with 51 additions and 11 deletions
+21 -4
View File
@@ -47,13 +47,30 @@ for a in s
e = $ "s-#{a[0]}"
(f = -> e.innerHTML = a[4]+a[1][a[3]])()
e.onclick = -> f(a[3] = (a[3]+1)%a[1].length)
$('start').onclick = ->
$('step-1').style.display = 'none'
$('step-2').style.display = 'block'
$('step-2').style.backgroundImage = "url(css/help-#{s[0][3]}.png)"
$('step-2').onclick = ->
$('step-2').style.display = 'none'
$('step-3').style.display = 'block'
init s[0][3], s[1][3], s[2][3], s[3][3]
$('step-5').onclick = ->
window.location.reload()
hasWebGL = ->
gl = null
canvas = document.createElement('canvas');
try
gl = canvas.getContext("webgl")
if not gl?
try
gl = canvas.getContext("experimental-webgl")
return gl?
if not hasWebGL()
getWebGL = $('start')
getWebGL.innerHTML = 'WebGL is not supported!'
getWebGL.onclick = ->
window.location.href = 'http://get.webgl.org/'
else
$('start').onclick = ->
$('step-1').style.display = 'none'
$('step-2').style.display = 'block'
$('step-2').style.backgroundImage = "url(css/help-#{s[0][3]}.png)"
+30 -7
View File
@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.6.3
(function() {
var $, a, init, s, u, _fn, _i, _len;
var $, a, getWebGL, hasWebGL, init, s, u, _fn, _i, _len;
$ = function(_) {
return document.getElementById(_);
@@ -64,12 +64,6 @@
_fn(a);
}
$('start').onclick = function() {
$('step-1').style.display = 'none';
$('step-2').style.display = 'block';
return $('step-2').style.backgroundImage = "url(css/help-" + s[0][3] + ".png)";
};
$('step-2').onclick = function() {
$('step-2').style.display = 'none';
$('step-3').style.display = 'block';
@@ -80,4 +74,33 @@
return window.location.reload();
};
hasWebGL = function() {
var canvas, gl;
gl = null;
canvas = document.createElement('canvas');
try {
gl = canvas.getContext("webgl");
} catch (_error) {}
if (gl == null) {
try {
gl = canvas.getContext("experimental-webgl");
} catch (_error) {}
}
return gl != null;
};
if (!hasWebGL()) {
getWebGL = $('start');
getWebGL.innerHTML = 'WebGL is not supported!';
getWebGL.onclick = function() {
return window.location.href = 'http://get.webgl.org/';
};
} else {
$('start').onclick = function() {
$('step-1').style.display = 'none';
$('step-2').style.display = 'block';
return $('step-2').style.backgroundImage = "url(css/help-" + s[0][3] + ".png)";
};
}
}).call(this);