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 Conformance Tests: Verify validation for active built-in attribs
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/desktop-gl-constants.js"></script>
14 <script src=
"../../js/js-test-pre.js"></script>
15 <script src=
"../../js/webgl-test-utils.js"></script>
18 <div id=
"description"></div>
19 <canvas id=
"canvas" style=
"width: 64px; height: 64px;"> </canvas>
20 <div id=
"console"></div>
21 <script id=
"vs" type=
"x-shader/x-vertex">#version
300 es
23 gl_Position = vec4(gl_VertexID %
2, (gl_VertexID/
2) %
2,
0,
1);
27 <script id=
"fs" type=
"x-shader/x-fragment">#version
300 es
28 precision mediump float;
31 fragColor = vec4(
0,
1,
0,
1);
37 description("This test verifies validation for active built-in attribs.");
41 var wtu
= WebGLTestUtils
;
42 var canvas
= document
.getElementById("canvas");
43 var gl
= wtu
.create3DContext(canvas
, null, 2);
46 testFailed("WebGL context does not exist");
48 testPassed("WebGL context exists");
52 var activeInfo
, attribLoc
;
55 var prog
= wtu
.setupProgram(gl
, ["vs", "fs"]);
57 testFailed("Set up program failed");
60 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "No GL error from set up");
62 var numActive
= gl
.getProgramParameter(prog
, gl
.ACTIVE_ATTRIBUTES
);
64 testFailed('ACTIVE_ATTRIBUTES should be 1.');
67 testPassed('ACTIVE_ATTRIBUTES should be 1.');
69 activeInfo
= gl
.getActiveAttrib(prog
, 0);
71 testFailed('getActiveAttrib should return an info object.');
75 shouldBe('activeInfo.name', '"gl_VertexID"');
76 attribLoc
= gl
.getAttribLocation(prog
, 'gl_VertexID');
77 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be able to request the location of a built-in.");
78 shouldBe('attribLoc', '-1');
81 var successfullyParsed
= true;
83 <script src=
"../../js/js-test-post.js"></script>