Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / attribs / gl-disabled-vertex-attrib.html
blobf4f8997449c24f3c1455b612bd26165e185937d0
1 <!--
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.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
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>
15 </head>
16 <body>
17 <canvas id="example" width="50" height="50">
18 </canvas>
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;
24 varying vec4 v_color;
25 bool isCorrectColor(vec4 v) {
26 return v.x == 0.0 && v.y == 0.0 && v.z == 0.0 && v.w == 1.0;
28 void main() {
29 gl_Position = a_position;
30 v_color = isCorrectColor(a_color) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1);
32 </script>
34 <script id="fshader" type="x-shader/x-fragment">
35 precision mediump float;
36 varying vec4 v_color;
37 void main() {
38 gl_FragColor = v_color;
40 </script>
42 <script>
43 "use strict";
44 var wtu = WebGLTestUtils;
45 description();
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(
62 gl,
63 ['vshader', 'fshader'],
64 ['a_position', 'a_color'],
65 [positionLocation, colorLocation]);
66 var gridRes = 1;
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;
74 </script>
75 <script src="../../js/js-test-post.js"></script>
77 </body>
78 </html>