2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL clear conformance test.
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/js-test-pre.js"></script>
14 <script src=
"../../js/webgl-test-utils.js"> </script>
17 <canvas id=
"example" width=
"1" height=
"1" style=
"width: 256px; height: 48px;"></canvas>
18 <div id=
"description"></div><div id=
"console"></div>
21 description("Test clear.");
22 var wtu
= WebGLTestUtils
;
23 var gl
= wtu
.create3DContext("example");
24 var program
= wtu
.setupTexturedQuad(gl
);
26 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
27 wtu
.checkCanvas(gl
, [0,0,0,0], "should be 0,0,0,0");
29 gl
.clearColor(1,1,1,1);
30 gl
.clear(gl
.COLOR_BUFFER_BIT
);
31 wtu
.checkCanvas(gl
, [255,255,255,255], "should be 255,255,255,255");
33 gl
.clearColor(0,0,0,0);
34 gl
.clear(gl
.COLOR_BUFFER_BIT
);
35 wtu
.checkCanvas(gl
, [0,0,0,0], "should be 0,0,0,0");
37 gl
.colorMask(false, false, false, true);
38 gl
.clearColor(1,1,1,1);
39 gl
.clear(gl
.COLOR_BUFFER_BIT
);
40 wtu
.checkCanvas(gl
, [0,0,0,255], "should be 0,0,0,255");
42 var tex
= gl
.createTexture();
43 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
45 gl
.TEXTURE_2D
, 0, gl
.RGBA
, 1, 1, 0, gl
.RGBA
, gl
.UNSIGNED_BYTE
,
46 new Uint8Array([128, 128, 128, 192]));
48 gl
.disable(gl
.DEPTH_TEST
);
50 gl
.colorMask(true, true, true, true);
51 gl
.drawArrays(gl
.TRIANGLES
, 0, 6);
52 wtu
.checkCanvas(gl
, [128,128,128,192], "should be 128,128,128,192");
54 gl
.colorMask(false, false, false, true);
55 gl
.clearColor(1,1,1,1);
56 gl
.clear(gl
.COLOR_BUFFER_BIT
);
57 wtu
.checkCanvas(gl
, [128,128,128,255], "should be 128,128,128,255");
59 // TODO: Test depth and stencil clearing.
62 var successfullyParsed
= true;
64 <script src=
"../../js/js-test-post.js"></script>