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 Disabled Vertex Attrib 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=
"50" height=
"50">
19 <div id=
"description"></div>
20 <div id=
"console"></div>
21 <script id=
"vshader" type=
"x-shader/x-vertex">
22 attribute vec4 a_position;
23 attribute vec4 a_color;
25 bool isCorrectColor(vec4 v) {
26 return v.x ==
0.0 && v.y ==
0.0 && v.z ==
0.0 && v.w ==
1.0;
29 gl_Position = a_position;
30 v_color = isCorrectColor(a_color) ? vec4(
0,
1,
0,
1) : vec4(
1,
0,
0,
1);
34 <script id=
"fshader" type=
"x-shader/x-fragment">
35 precision mediump float;
38 gl_FragColor = v_color;
44 var wtu
= WebGLTestUtils
;
47 var gl
= wtu
.create3DContext("example");
49 var numVertexAttribs
= gl
.getParameter(gl
.MAX_VERTEX_ATTRIBS
);
50 for (var ii
= 0; ii
< numVertexAttribs
; ++ii
) {
51 var colorLocation
= (ii
+ 1) % numVertexAttribs
;
52 var positionLocation
= colorLocation
? 0 : 1;
54 if (positionLocation
!= 0) {
55 // We need to create a new 3d context for testing attrib 0
56 // since we've already effected attrib 0 on other tests.
57 gl
= wtu
.create3DContext();
60 debug("testing attrib: " + colorLocation
);
61 var program
= wtu
.setupProgram(
63 ['vshader', 'fshader'],
64 ['a_position', 'a_color'],
65 [positionLocation
, colorLocation
]);
67 wtu
.setupIndexedQuad(gl
, gridRes
, positionLocation
);
68 wtu
.clearAndDrawIndexedQuad(gl
, gridRes
);
69 wtu
.checkCanvas(gl
, [0, 255, 0, 255], "should be green");
71 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "should be no errors");
73 var successfullyParsed
= true;
75 <script src=
"../../js/js-test-post.js"></script>