forked from stepheneb/seasons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-for-webgl.html
63 lines (54 loc) · 2.11 KB
/
test-for-webgl.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<html>
<head>
<title>Test for WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
var gl;
function browserSupportsWebGL() {
if (window.WebGLRenderingContext === undefined) {
return false
} else {
return true
}
}
function webglContextCreationErrorHandler(evt) {
if (evt.statusMessage) {
document.getElementById("status-message").textContent = evt.statusMessage;
}
};
function webGLTest() {
var canvas = document.getElementById("canvas");
var results = document.getElementById("results");
canvas.addEventListener("webglcontextcreationerror", webglContextCreationErrorHandler, false);
try {
gl = canvas.getContext("experimental-webgl");
} catch(e) {
}
var result = "";
if (!gl && browserSupportsWebGL()) {
result = "Your browser supports WebGL but there was an error starting up. This may mean you need to update your video drivers. Try: <a href='http://get.webgl.org/troubleshooting'>http://get.webgl.org/troubleshooting</a>";
} else if (!gl) {
result = "Your browser does not support WebGL. Try: <a href='http://get.webgl.org'>http://get.webgl.org</a>";
} else {
result = "Your browser supports WebGL";
};
results.innerHTML = result;
}
</script>
<body onload="webGLTest();">
<h3>Test Browser for WebGL Capability</h3>
<h4>Results</h4>
<p id="results"></p>
<h4>Browser-specific status message</h4>
<p id="status-message"></p>
<h4>Test input element for Chrome 10 bug (versions older than 10.0.648.204)</h4>
<p>Chrome bug: <a href="http://code.google.com/p/chromium/issues/detail?id=71624">experimental-webgl" breaks page on chrome 10</a></p>
<form id="form1">
<label id="label1" for="input1">Enter text: </label>
<input type="text" id="input1" name="input1" />
<input type="submit" value="Submit" />
</form>
<p>On Chrome 10 versions older than 10.0.648.204 on Windows you will not see text you enter into the input field.</p>
<canvas id="canvas" style="border: none;" width="100" height="100"></canvas>
</body>
</html>