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>gl-fragcoord 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=
"32" height=
"32">
19 <div id=
"description"></div>
20 <div id=
"console"></div>
21 <script id=
"vshader" type=
"x-shader/x-vertex">
22 attribute vec4 vPosition;
25 gl_Position = vPosition;
29 <script id=
"fshader" type=
"x-shader/x-fragment">
30 precision mediump float;
34 gl_FrontFacing ?
1.0 :
0.0,
35 gl_FrontFacing ?
0.0 :
1.0,
45 description("tests gl_FrontFacing");
47 var wtu
= WebGLTestUtils
;
48 var gl
= wtu
.create3DContext("example");
49 var program
= wtu
.setupProgram(gl
, ["vshader", "fshader"], ["vPosition"]);
52 wtu
.setupIndexedQuad(gl
, gridRes
, 0, true);
54 gl
.clear(gl
.COLOR_BUFFER_BIT
| gl
.DEPTH_BUFFER_BIT
);
55 gl
.drawElements(gl
.TRIANGLES
, gridRes
* gridRes
* 6, gl
.UNSIGNED_SHORT
, 0);
56 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "no errors from draw");
58 var step
= 32 / gridRes
;
59 var halfStep
= step
/ 2;
60 var quarterStep
= halfStep
/ 2;
61 for (var xx
= 0; xx
< 32; xx
+= step
) {
62 for (var yy
= 0; yy
< 32; yy
+= step
) {
63 for (var ii
= 0; ii
< 2; ++ii
) {
69 var msg
= "should be " + color
;
72 xx
+ quarterStep
+ halfStep
* ii
,
73 yy
+ quarterStep
+ halfStep
* ii
,
81 var successfullyParsed
= true;
83 <script src=
"../../../js/js-test-post.js"></script>