OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2009 The Chromium Authors. 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 are | |
6 met: | |
7 | |
8 * Redistributions of source code must retain the above copyright | |
9 notice, this list of conditions and the following disclaimer. | |
10 * Redistributions in binary form must reproduce the above | |
11 copyright notice, this list of conditions and the following disclaimer | |
12 in the documentation and/or other materials provided with the | |
13 distribution. | |
14 * Neither the name of Google Inc. nor the names of its | |
15 contributors may be used to endorse or promote products derived from | |
16 this software without specific prior written permission. | |
17 | |
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 --> | |
30 <html> | |
31 <head> | |
32 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
33 <script src="../resources/js-test-pre.js"></script> | |
34 <script src="resources/webgl-test.js"></script> | |
35 </head> | |
36 <body> | |
37 <div id="description"></div> | |
38 <div id="console"></div> | |
39 | |
40 <script> | |
41 description("Tests the WebGLUniformLocation API"); | |
42 | |
43 var contextA = create3DContext(); | |
44 var contextB = create3DContext(); | |
45 var programA1 = loadStandardProgram(contextA); | |
46 var programA2 = loadStandardProgram(contextA); | |
47 var programB = loadStandardProgram(contextB); | |
48 var programS = loadProgram(contextA, "resources/structUniformShader.vert", "reso
urces/fragmentShader.frag"); | |
49 var programV = loadProgram(contextA, "resources/floatUniformShader.vert", "resou
rces/noopUniformShader.frag"); | |
50 var locationA = contextA.getUniformLocation(programA1, 'u_modelViewProjMatrix'); | |
51 var locationB = contextB.getUniformLocation(programB, 'u_modelViewProjMatrix'); | |
52 var locationSx = contextA.getUniformLocation(programS, "u_struct.x"); | |
53 var locationArray0 = contextA.getUniformLocation(programS, "u_array[0]"); | |
54 var locationArray1 = contextA.getUniformLocation(programS, "u_array[1]"); | |
55 var locationVec4 = contextA.getUniformLocation(programV, "fval4"); | |
56 | |
57 var vec = [1, 2, 3, 4]; | |
58 var mat = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; | |
59 | |
60 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA
2)"); | |
61 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMat
rix4fv(locationA, false, mat)"); | |
62 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA
1)"); | |
63 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(lo
cationA, false, mat)"); | |
64 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(nu
ll, false, mat)"); | |
65 | |
66 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS
)"); | |
67 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationS
x, 3)"); | |
68 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationA
rray0, 4.0)"); | |
69 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationA
rray1, 5.0)"); | |
70 | |
71 shouldBe("contextA.getUniform(programS, locationSx)", "3"); | |
72 shouldBe("contextA.getUniform(programS, locationArray0)", "4.0"); | |
73 shouldBe("contextA.getUniform(programS, locationArray1)", "5.0"); | |
74 | |
75 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programV
)"); | |
76 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform4fv(location
Vec4, vec)"); | |
77 shouldBe("contextA.getUniform(programV, locationVec4)", "vec"); | |
78 | |
79 shouldBeNull("contextA.getUniformLocation(programV, \"IDontExist\")"); | |
80 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(program
A1)"); | |
81 // After linking all boxes are bad. | |
82 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMat
rix4fv(locationA, false, mat)"); | |
83 | |
84 // after re-linking the same program, all uniform locations become invalid. | |
85 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS
)"); | |
86 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(program
S)"); | |
87 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniform1i(
locationSx, 3)"); | |
88 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getUniform
(programS, locationSx)"); | |
89 | |
90 // Retrieve the locations again, and they should be good. | |
91 locationSx = contextA.getUniformLocation(programS, "u_struct.x"); | |
92 locationArray0 = contextA.getUniformLocation(programS, "u_array[0]"); | |
93 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationS
x, 3)"); | |
94 shouldBe("contextA.getUniform(programS, locationSx)", "3"); | |
95 | |
96 successfullyParsed = true; | |
97 </script> | |
98 | |
99 <script src="../resources/js-test-post.js"></script> | |
100 </body> | |
101 </html> | |
OLD | NEW |