OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML> | |
2 <html> | |
3 <head> | |
4 <meta charset="utf-8"> | |
5 <title>WebGL required buffer clear behaviour test</title> | |
6 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
7 <script src="../resources/js-test-pre.js"></script> | |
8 <script src="resources/webgl-test.js"> </script> | |
9 <script src="resources/webgl-test-utils.js"> </script> | |
10 <style type="text/css"> | |
11 body { | |
12 height: 3000px; | |
13 } | |
14 </style> | |
15 <script type="text/javascript"> | |
16 | |
17 var iter = 0; | |
18 var gl1; | |
19 | |
20 var wtu = WebGLTestUtils; | |
21 | |
22 function timer() { | |
23 if (iter == 0) { | |
24 // some random hacky stuff to make sure that we get a compositing step | |
25 window.scrollBy(0, 10); | |
26 window.scrollBy(0, -10); | |
27 iter++; | |
28 | |
29 setTimeout(timer, 500); | |
30 } else if (iter == 1) { | |
31 function clear(gl) { | |
32 // scissor was set earlier | |
33 gl.clearColor(0, 0, 1, 1); | |
34 gl.clear(gl.COLOR_BUFFER_BIT); | |
35 | |
36 wtu.checkCanvasRect(gl, 0, 10, 10, 10, [0, 0, 255, 255], "cleared co
rner should be blue, stencil should be preserved"); | |
37 wtu.checkCanvasRect(gl, 0, 0, 10, 10, [0, 0, 0, 0], "remainder of bu
ffer should be cleared"); | |
38 } | |
39 clear(gl1); | |
40 | |
41 finishTest(); | |
42 } | |
43 } | |
44 | |
45 function go() { | |
46 description("This test ensures WebGL implementations correctly clear the dra
wing buffer on composite if preserveDrawingBuffer is false."); | |
47 | |
48 debug(""); | |
49 | |
50 gl1 = create3DContext(document.getElementById("c")); | |
51 if (!gl1) { | |
52 finishTest(); | |
53 return; | |
54 } | |
55 | |
56 shouldBeTrue("gl1 != null"); | |
57 shouldBeTrue('gl1.getContextAttributes().preserveDrawingBuffer == false'); | |
58 | |
59 function init(gl) { | |
60 gl.clearColor(1, 0, 0, 1); | |
61 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_B
IT); | |
62 | |
63 // enable scissor here, before compositing, to make sure it's correctly | |
64 // ignored and restored | |
65 gl.scissor(0, 10, 10, 10); | |
66 gl.enable(gl.SCISSOR_TEST); | |
67 } | |
68 | |
69 init(gl1); | |
70 | |
71 setTimeout(timer, 500); | |
72 } | |
73 | |
74 window.addEventListener("load", go, false); | |
75 | |
76 successfullyParsed = true; | |
77 </script> | |
78 </head> | |
79 <body> | |
80 <div id="description"></div> | |
81 <canvas width="20" height="20" style="border: 1px solid blue;" id="c"></canvas> | |
82 <div id="console"></div> | |
83 </body> | |
84 </html> | |
OLD | NEW |