blob: 0895eb2c2620323a6c9b4990bc050e32df1c15e0 [file] [log] [blame]
jamesr@google.com250664d2012-08-27 22:42:30 +00001<!DOCTYPE html>
2<html>
3<head>
4<style type="text/css" media="screen">
5canvas {
6 margin: 20px;
7 width: 200px;
8 height: 200px;
9 padding: 0 0;
10}
11.border {
12 border: 1px solid black;
13}
14</style>
15<script>
jamesr@google.com250664d2012-08-27 22:42:30 +000016function initWebGL()
17{
18 var canvas = document.getElementById('canvas');
19 var gl = canvas.getContext("experimental-webgl", {'antialias': false});
20 if (!gl) {
21 alert("No WebGL context found");
22 return null;
23 }
24
25 return gl;
26}
27
28var gl = null;
29
30function init()
31{
32 gl = initWebGL();
33 gl.viewport(0, 0, 200, 200);
34 gl.clearColor(1, 0, 0, 1); // red
35 gl.clear(gl.COLOR_BUFFER_BIT);
36 if (window.testRunner) {
commit-queue@webkit.org8e8c3bd2017-05-04 21:46:39 +000037 testRunner.displayAndTrackRepaints();
jamesr@google.com250664d2012-08-27 22:42:30 +000038 testRunner.dumpAsText(true);
39 drawGreen();
40 } else
41 window.setTimeout(drawGreen, 50);
42}
43
44function drawGreen()
45{
46 gl.clearColor(0, 1, 0, 1); // green
47 gl.clear(gl.COLOR_BUFFER_BIT);
48 if (window.testRunner) {
commit-queue@webkit.org8e8c3bd2017-05-04 21:46:39 +000049 testRunner.displayAndTrackRepaints();
50 testRunner.displayAndTrackRepaints();
jamesr@google.com250664d2012-08-27 22:42:30 +000051 } else
52 window.setInterval(function() {
53 document.getElementById('canvas').classList.toggle('border');
54 }, 50);
55}
56
57</script>
58</head>
59<body onload="init()">
60<canvas id="canvas" width="200" height="200"></canvas>
61</body>
62</html>