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>Check that the canvas is NOT recomposited after unsucessful draw call
</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 black;
20 border:
1px solid black;
21 background-color: #ffffff;
27 This test must be run manually.
29 This test tests that a canvas is cleared
30 even when a draw call has a zero count.
32 You should see three
<span class=
"correct">white rectangles
</span>
33 with black outlines on success.
35 <canvas id='c1'
></canvas>
36 <canvas id='c2'
></canvas>
37 <canvas id='c3'
></canvas>
38 <div id=
"console"></div>
39 <script id=
"vshader" type=
"x-shader/x-vertex">
41 gl_Position = vec4(
0,
0,
0,
1);
44 <script id=
"fshader" type=
"x-shader/x-fragment">
45 precision mediump float;
52 var wtu
= WebGLTestUtils
;
53 var c1
= document
.getElementById("c1");
54 var c2
= document
.getElementById("c2");
55 var c3
= document
.getElementById("c2");
56 var gl1
= wtu
.create3DContext(c1
);
57 var gl2
= wtu
.create3DContext(c2
);
58 var gl3
= wtu
.create3DContext(c2
);
59 gl1
.clearColor(0,1,0,1);
60 gl1
.clear(gl1
.COLOR_BUFFER_BIT
);
61 gl2
.clearColor(0,1,0,1);
62 gl2
.clear(gl2
.COLOR_BUFFER_BIT
);
63 gl3
.clearColor(0,1,0,1);
64 gl3
.clear(gl2
.COLOR_BUFFER_BIT
);
66 wtu
.waitForComposite(function() {
68 gl1
.drawArrays(gl1
.TRIANGLES
, 0, 0);
69 wtu
.glErrorShouldBe(gl1
, gl1
.NO_ERROR
, "no errors");
72 wtu
.waitForComposite(function() {
74 var buf
= gl2
.createBuffer();
75 gl2
.bindBuffer(gl2
.ELEMENT_ARRAY_BUFFER
, buf
);
76 gl2
.bufferData(gl2
.ELEMENT_ARRAY_BUFFER
, new Uint8Array(1), gl2
.STATIC_DRAW
);
77 gl2
.drawElements(gl2
.TRIANGLES
, 0, gl2
.UNSIGNED_SHORT
, 0);
78 wtu
.glErrorShouldBe(gl2
, gl2
.NO_ERROR
, "no errors");
81 wtu
.waitForComposite(function() {
82 // test draw with program.
83 wtu
.setupProgram(gl3
, ["vshader", "fshader"]);
84 gl1
.drawArrays(gl3
.TRIANGLES
, 0, 0);
85 wtu
.glErrorShouldBe(gl3
, gl2
.NO_ERROR
, "no errors");