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 Scissor 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 border:
1px solid #
000;
24 <canvas id=
"canvas1" width=
"16" height=
"16"> </canvas>
25 <canvas id=
"canvas2" width=
"16" height=
"16"> </canvas>
26 <div id=
"description"></div>
27 <div id=
"console"></div>
30 description("Check if glScissor setting works.");
32 var wtu
= WebGLTestUtils
;
34 function test(canvas
, attribs
) {
35 var gl
= wtu
.create3DContext(canvas
, attribs
);
38 gl
.disable(gl
.SCISSOR_TEST
);
39 gl
.clearColor(0,0,0,0);
40 gl
.clear(gl
.COLOR_BUFFER_BIT
);
41 gl
.enable(gl
.SCISSOR_TEST
);
44 for (var ii
= 0; ii
< size
; ++ii
) {
45 // clear a portion of the WebGL drawing buffer
46 gl
.scissor(ii
, ii
, 1, 1);
50 for (var ii
= 0; ii
< size
; ++ii
) {
51 wtu
.checkCanvasRect(gl
, 0, ii
, ii
, 1, [0, 0, 0, 0], "should be black");
52 wtu
.checkCanvasRect(gl
, ii
, ii
, 1, 1, [0, 255, 0, 255], "should be green");
53 wtu
.checkCanvasRect(gl
, ii
+ 1, ii
, size
- ii
- 1, 1, [0, 0, 0, 0], "should be black");
58 testFailed("context does not exist");
60 testPassed("context exists");
63 debug("test with clear");
65 gl
.clearColor(0, 1, 0, 1);
66 gl
.clear(gl
.COLOR_BUFFER_BIT
);
69 wtu
.setupColorQuad(gl
);
72 debug("test with draw");
74 wtu
.drawFloatColorQuad(gl
, [0, 1, 0, 1]);
77 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "there should be no errors");
81 debug("test antialias: false");
82 test(document
.getElementById("canvas1"), {antialias
: false});
85 debug("test antialias: true");
86 test(document
.getElementById("canvas2"), {antialias
: true});
89 var successfullyParsed
= true;
92 <script src=
"../../js/js-test-post.js"></script>