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 getActiveAttrib conformance 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=
"16" height=
"16"></canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
20 <script id=
"vshader" type=
"x-shader/x-vertex">
21 attribute $type attr0;
24 gl_Position = vec4(
0,
0,
0, attr0$access);
27 <script id=
"fshader" type=
"x-shader/x-fragment">
30 gl_FragColor = vec4(
0,
1,
0,
1);
35 description("Tests getActiveAttrib for various types");
37 var wtu
= WebGLTestUtils
;
38 var gl
= wtu
.create3DContext("example");
41 { glType
: gl
.FLOAT
, size
: 1, type
: 'float', access
: ''},
42 { glType
: gl
.FLOAT_VEC2
, size
: 1, type
: 'vec2', access
: '[1]'},
43 { glType
: gl
.FLOAT_VEC3
, size
: 1, type
: 'vec3', access
: '[2]'},
44 { glType
: gl
.FLOAT_VEC4
, size
: 1, type
: 'vec4', access
: '[3]'},
45 { glType
: gl
.FLOAT_MAT2
, size
: 1, type
: 'mat2', access
: '[1][1]'},
46 { glType
: gl
.FLOAT_MAT3
, size
: 1, type
: 'mat3', access
: '[2][2]'},
47 { glType
: gl
.FLOAT_MAT4
, size
: 1, type
: 'mat4', access
: '[3][3]'},
50 var source
= document
.getElementById('vshader').text
;
51 var fs
= wtu
.loadShaderFromScript(gl
, 'fshader', gl
.FRAGMENT_SHADER
);
52 for (var tt
= 0; tt
< tests
.length
; ++tt
) {
54 var vs
= wtu
.loadShader(
56 source
.replace('$type', t
.type
).replace('$access', t
.access
),
58 var program
= wtu
.setupProgram(gl
, [vs
, fs
]);
59 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "no errors from setup");
60 var numAttribs
= gl
.getProgramParameter(program
, gl
.ACTIVE_ATTRIBUTES
);
62 for (var ii
= 0; ii
< numAttribs
; ++ii
) {
63 var info
= gl
.getActiveAttrib(program
, ii
);
64 if (info
.name
== 'attr0') {
66 assertMsg(info
.type
== t
.glType
,
67 "type must be " + wtu
.glEnumToString(gl
, t
.glType
) + " was " +
68 wtu
.glEnumToString(gl
, info
.type
));
69 assertMsg(info
.size
== t
.size
,
70 "size must be " + t
.size
+ ' was ' + info
.size
);
74 testFailed("attrib 'attr0' not found");
78 var successfullyParsed
= true;
80 <script src=
"../../js/js-test-post.js"></script>