OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
3 Use of this source code is governed by a BSD-style license that can be | |
4 found in the LICENSE file. | |
5 --> | |
6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
7 "http://www.w3.org/TR/html4/loose.dtd"> | |
8 <html> | |
9 <head> | |
10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
11 <title>WebGL Scissor Test</title> | |
12 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
13 <script src="../resources/desktop-gl-constants.js" type="text/javascript"></scri
pt> | |
14 <script src="../../debug/webgl-debug.js"></script> | |
15 <script src="../resources/js-test-pre.js"></script> | |
16 <script src="resources/webgl-test-utils.js"></script> | |
17 </head> | |
18 <body> | |
19 <div id="description"></div> | |
20 <div id="console"></div> | |
21 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"> </c
anvas> | |
22 <script> | |
23 description("Check if glScissor setting works."); | |
24 | |
25 debug(""); | |
26 debug("Canvas.getContext"); | |
27 | |
28 var wtu = WebGLTestUtils; | |
29 var gl = wtu.create3DContext(document.getElementById("canvas")); | |
30 if (!gl) { | |
31 testFailed("context does not exist"); | |
32 } else { | |
33 testPassed("context exists"); | |
34 | |
35 debug(""); | |
36 | |
37 gl.clearColor(0,0,0,0); | |
38 gl.clear(gl.COLOR_BUFFER_BIT); | |
39 | |
40 // clear a portion of our FBO | |
41 gl.enable(gl.SCISSOR_TEST); | |
42 gl.scissor(0, 0, 1, 1); | |
43 gl.clearColor(0,1,0,1); | |
44 gl.clear(gl.COLOR_BUFFER_BIT); | |
45 | |
46 var b = new Uint8Array(2 * 2 * 4); | |
47 gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, b); | |
48 | |
49 function checkPixel(b, x, y, color) { | |
50 var offset = (y * 2 + x) * 4; | |
51 var match = true; | |
52 for (var c = 0; c < 4; ++c) { | |
53 if (b[offset + c] != color[c] * 255) { | |
54 match = false; | |
55 break; | |
56 } | |
57 } | |
58 assertMsg(match, "pixel at " + x + ", " + y + " is expected value"); | |
59 } | |
60 | |
61 checkPixel(b, 0, 0, [0, 1, 0, 1]); | |
62 checkPixel(b, 1, 0, [0, 0, 0, 0]); | |
63 checkPixel(b, 0, 1, [0, 0, 0, 0]); | |
64 checkPixel(b, 1, 1, [0, 0, 0, 0]); | |
65 } | |
66 | |
67 debug(""); | |
68 successfullyParsed = true; | |
69 | |
70 </script> | |
71 <script src="../resources/js-test-post.js"></script> | |
72 | |
73 <script> | |
74 </script> | |
75 | |
76 </body> | |
77 </html> | |
OLD | NEW |