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 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
12 <script src=
"../../js/js-test-pre.js"></script>
13 <script src=
"../../js/webgl-test-utils.js"></script>
16 <div id=
"description"></div>
17 <div id=
"console"></div>
21 description("Test of getActiveAttrib and getActiveUniform");
23 var wtu
= WebGLTestUtils
;
24 var context
= wtu
.create3DContext();
25 var context2
= wtu
.create3DContext();
26 var program
= wtu
.loadStandardProgram(context
);
27 var program2
= wtu
.loadProgramFromFile(context2
,
28 "../../resources/intArrayUniformShader.vert",
29 "../../resources/noopUniformShader.frag");
31 wtu
.glErrorShouldBe(context
, context
.NO_ERROR
);
32 shouldBe("context.getActiveUniform(program, 0).name", "'u_modelViewProjMatrix'");
33 shouldBe("context.getActiveUniform(program, 0).type", "context.FLOAT_MAT4");
34 shouldBe("context.getActiveUniform(program, 0).size", "1");
35 shouldBeNull("context.getActiveUniform(program, 1)");
36 wtu
.glErrorShouldBe(context
, context
.INVALID_VALUE
);
37 shouldBeNull("context.getActiveUniform(program, -1)");
38 wtu
.glErrorShouldBe(context
, context
.INVALID_VALUE
);
39 shouldThrow("context.getActiveUniform(null, 0)");
40 wtu
.glErrorShouldBe(context
, context
.NO_ERROR
);
42 // we don't know the order the attribs will appear.
44 context
.getActiveAttrib(program
, 0),
45 context
.getActiveAttrib(program
, 1)
47 for (var ii
= 0; ii
< info
.length
; ++ii
)
48 shouldBeNonNull("info[ii]");
51 { name
: 'a_normal', type
: context
.FLOAT_VEC3
, size
: 1 },
52 { name
: 'a_vertex', type
: context
.FLOAT_VEC4
, size
: 1 }
55 if (info
[0].name
!= expected
[0].name
) {
61 for (var ii
= 0; ii
< info
.length
; ++ii
) {
62 shouldBe("info[ii].name", "expected[ii].name");
63 shouldBe("info[ii].type", "expected[ii].type");
64 shouldBe("info[ii].size", "expected[ii].size");
67 // we don't know the order the uniforms will appear.
69 context2
.getActiveUniform(program2
, 0),
70 context2
.getActiveUniform(program2
, 1)
72 for (var ii
= 0; ii
< info2
.length
; ++ii
)
73 shouldBeNonNull("info2[ii]");
76 { name
: 'ival', type
: context2
.INT
, size
: 1 },
77 { name
: 'ival2[0]', type
: context2
.INT
, size
: 2 }
80 if (info2
[0].name
!= expected2
[0].name
) {
86 for (var ii
= 0; ii
< info2
.length
; ++ii
) {
87 shouldBe("info2[ii].name", "expected2[ii].name");
88 shouldBe("info2[ii].type", "expected2[ii].type");
89 shouldBe("info2[ii].size", "expected2[ii].size");
92 shouldBeNull("context.getActiveAttrib(program, 2)");
93 wtu
.glErrorShouldBe(context
, context
.INVALID_VALUE
);
94 shouldBeNull("context.getActiveAttrib(program, -1)");
95 wtu
.glErrorShouldBe(context
, context
.INVALID_VALUE
);
96 shouldThrow("context.getActiveAttrib(null, 0)");
97 wtu
.glErrorShouldBe(context
, context
.NO_ERROR
);
99 wtu
.glErrorShouldBe(context2
, context
.NO_ERROR
);
101 debug("Check trying to get attribs from different context");
102 shouldBeNull("context2.getActiveAttrib(program, 0)");
103 wtu
.glErrorShouldBe(context2
, context2
.INVALID_OPERATION
);
104 shouldBeNull("context2.getActiveUniform(program, 0)");
105 wtu
.glErrorShouldBe(context2
, context2
.INVALID_OPERATION
);
107 debug("Check trying to get attribs from deleted program");
108 context
.deleteProgram(program
);
109 shouldBeNull("context.getActiveUniform(program, 0)");
110 wtu
.glErrorShouldBe(context
, context
.INVALID_VALUE
);
111 shouldBeNull("context.getActiveAttrib(program, 0)");
112 wtu
.glErrorShouldBe(context
, context
.INVALID_VALUE
);
114 var successfullyParsed
= true;
117 <script src=
"../../js/js-test-post.js"></script>