|
1 <!-- |
|
2 Copyright (c) 2011 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> |
|
7 <html> |
|
8 <head> |
|
9 <meta charset="utf-8"> |
|
10 <title>WebGL clear conformance test.</title> |
|
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
|
12 <script src="../../resources/js-test-pre.js"></script> |
|
13 <script src="../resources/webgl-test.js"> </script> |
|
14 <script src="../resources/webgl-test-utils.js"> </script> |
|
15 </head> |
|
16 <body> |
|
17 <canvas id="example" width="1" height="1" style="width: 256px; height: 48px;"></canvas> |
|
18 <div id="description"></div><div id="console"></div> |
|
19 <script> |
|
20 description("Test clear."); |
|
21 var wtu = WebGLTestUtils; |
|
22 var gl = wtu.create3DContext("example"); |
|
23 var program = wtu.setupTexturedQuad(gl); |
|
24 |
|
25 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup."); |
|
26 wtu.checkCanvas(gl, [0,0,0,0], "should be 0,0,0,0"); |
|
27 |
|
28 gl.clearColor(1,1,1,1); |
|
29 gl.clear(gl.COLOR_BUFFER_BIT); |
|
30 wtu.checkCanvas(gl, [255,255,255,255], "should be 255,255,255,255"); |
|
31 |
|
32 gl.clearColor(0,0,0,0); |
|
33 gl.clear(gl.COLOR_BUFFER_BIT); |
|
34 wtu.checkCanvas(gl, [0,0,0,0], "should be 0,0,0,0"); |
|
35 |
|
36 gl.colorMask(false, false, false, true); |
|
37 gl.clearColor(1,1,1,1); |
|
38 gl.clear(gl.COLOR_BUFFER_BIT); |
|
39 wtu.checkCanvas(gl, [0,0,0,255], "should be 0,0,0,255"); |
|
40 |
|
41 var tex = gl.createTexture(); |
|
42 gl.bindTexture(gl.TEXTURE_2D, tex); |
|
43 gl.texImage2D( |
|
44 gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, |
|
45 new Uint8Array([128, 128, 128, 192])); |
|
46 |
|
47 gl.disable(gl.DEPTH_TEST); |
|
48 gl.disable(gl.BLEND); |
|
49 gl.colorMask(true, true, true, true); |
|
50 gl.drawArrays(gl.TRIANGLES, 0, 6); |
|
51 wtu.checkCanvas(gl, [128,128,128,192], "should be 128,128,128,192"); |
|
52 |
|
53 gl.colorMask(false, false, false, true); |
|
54 gl.clearColor(1,1,1,1); |
|
55 gl.clear(gl.COLOR_BUFFER_BIT); |
|
56 wtu.checkCanvas(gl, [128,128,128,255], "should be 128,128,128,255"); |
|
57 |
|
58 // TODO: Test depth and stencil clearing. |
|
59 |
|
60 debug(""); |
|
61 successfullyParsed = true; |
|
62 </script> |
|
63 <script>finishTest();</script> |
|
64 </body> |
|
65 </html> |
|
66 |