OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (C) 2009 Apple Computer, Inc. All rights reserved. | |
3 | |
4 Redistribution and use in source and binary forms, with or without | |
5 modification, are permitted provided that the following conditions | |
6 are met: | |
7 1. Redistributions of source code must retain the above copyright | |
8 notice, this list of conditions and the following disclaimer. | |
9 2. Redistributions in binary form must reproduce the above copyright | |
10 notice, this list of conditions and the following disclaimer in the | |
11 documentation and/or other materials provided with the distribution. | |
12 | |
13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 --> | |
25 | |
26 <html> | |
27 <head> | |
28 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
29 <script src="../resources/js-test-pre.js"></script> | |
30 <script src="resources/webgl-test.js"></script> | |
31 </head> | |
32 <body> | |
33 <div id="description"></div> | |
34 <div id="console"></div> | |
35 | |
36 <script> | |
37 description("Test of getActiveAttrib and getActiveUniform"); | |
38 | |
39 var context = create3DContext(); | |
40 var context2 = create3DContext(); | |
41 var program = loadStandardProgram(context); | |
42 var program2 = loadProgram(context2, | |
43 "resources/intArrayUniformShader.vert", | |
44 "resources/noopUniformShader.frag"); | |
45 | |
46 glErrorShouldBe(context, context.NO_ERROR); | |
47 shouldBe("context.getActiveUniform(program, 0).name", "'u_modelViewProjMatrix'")
; | |
48 shouldBe("context.getActiveUniform(program, 0).type", "context.FLOAT_MAT4"); | |
49 shouldBe("context.getActiveUniform(program, 0).size", "1"); | |
50 shouldBeNull("context.getActiveUniform(program, 1)"); | |
51 glErrorShouldBe(context, context.INVALID_VALUE); | |
52 shouldBeNull("context.getActiveUniform(program, -1)"); | |
53 glErrorShouldBe(context, context.INVALID_VALUE); | |
54 shouldBeNull("context.getActiveUniform(null, 0)"); | |
55 glErrorShouldBe(context, context.INVALID_VALUE); | |
56 | |
57 // we don't know the order the attribs will appear. | |
58 var info = [ | |
59 context.getActiveAttrib(program, 0), | |
60 context.getActiveAttrib(program, 1) | |
61 ]; | |
62 for (var ii = 0; ii < info.length; ++ii) | |
63 shouldBeNonNull("info[ii]"); | |
64 | |
65 var expected = [ | |
66 { name: 'a_normal', type: context.FLOAT_VEC3, size: 1 }, | |
67 { name: 'a_vertex', type: context.FLOAT_VEC4, size: 1 } | |
68 ]; | |
69 | |
70 if (info[0].name != expected[0].name) { | |
71 t = info[0]; | |
72 info[0] = info[1]; | |
73 info[1] = t; | |
74 } | |
75 | |
76 for (var ii = 0; ii < info.length; ++ii) { | |
77 shouldBe("info[ii].name", "expected[ii].name"); | |
78 shouldBe("info[ii].type", "expected[ii].type"); | |
79 shouldBe("info[ii].size", "expected[ii].size"); | |
80 } | |
81 | |
82 // we don't know the order the uniforms will appear. | |
83 var info2 = [ | |
84 context2.getActiveUniform(program2, 0), | |
85 context2.getActiveUniform(program2, 1) | |
86 ]; | |
87 for (var ii = 0; ii < info2.length; ++ii) | |
88 shouldBeNonNull("info2[ii]"); | |
89 | |
90 var expected2 = [ | |
91 { name: 'ival', type: context2.INT, size: 1 }, | |
92 { name: 'ival2[0]', type: context2.INT, size: 2 } | |
93 ]; | |
94 | |
95 if (info2[0].name != expected2[0].name) { | |
96 t = info2[0]; | |
97 info2[0] = info2[1]; | |
98 info2[1] = t; | |
99 } | |
100 | |
101 for (var ii = 0; ii < info2.length; ++ii) { | |
102 shouldBe("info2[ii].name", "expected2[ii].name"); | |
103 shouldBe("info2[ii].type", "expected2[ii].type"); | |
104 shouldBe("info2[ii].size", "expected2[ii].size"); | |
105 } | |
106 | |
107 shouldBeNull("context.getActiveAttrib(program, 2)"); | |
108 glErrorShouldBe(context, context.INVALID_VALUE); | |
109 shouldBeNull("context.getActiveAttrib(program, -1)"); | |
110 glErrorShouldBe(context, context.INVALID_VALUE); | |
111 shouldBeNull("context.getActiveAttrib(null, 0)"); | |
112 glErrorShouldBe(context, context.INVALID_VALUE); | |
113 | |
114 glErrorShouldBe(context2, context.NO_ERROR); | |
115 | |
116 debug("Check trying to get attribs from different context"); | |
117 shouldBeNull("context2.getActiveAttrib(program, 0)"); | |
118 glErrorShouldBe(context2, context2.INVALID_OPERATION); | |
119 shouldBeNull("context2.getActiveUniform(program, 0)"); | |
120 glErrorShouldBe(context2, context2.INVALID_OPERATION); | |
121 | |
122 debug("Check trying to get attribs from deleted program"); | |
123 context.deleteProgram(program); | |
124 shouldBeNull("context.getActiveUniform(program, 0)"); | |
125 glErrorShouldBe(context, context.INVALID_VALUE); | |
126 shouldBeNull("context.getActiveAttrib(program, 0)"); | |
127 glErrorShouldBe(context, context.INVALID_VALUE); | |
128 | |
129 successfullyParsed = true; | |
130 </script> | |
131 | |
132 <script src="../resources/js-test-post.js"></script> | |
133 </body> | |
134 </html> | |
OLD | NEW |