| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright (c) 2011 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 <!DOCTYPE html> | |
| 31 <html> | |
| 32 <head> | |
| 33 <meta charset="utf-8"> | |
| 34 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
| 35 <script src="../resources/js-test-pre.js"></script> | |
| 36 <script src="resources/webgl-test.js"></script> | |
| 37 </head> | |
| 38 <body> | |
| 39 <div id="description"></div> | |
| 40 <div id="console"></div> | |
| 41 | |
| 42 <script> | |
| 43 description("Tests the WebGLUniformLocation API"); | |
| 44 | |
| 45 var contextA = create3DContext(); | |
| 46 var contextB = create3DContext(); | |
| 47 var programA1 = loadStandardProgram(contextA); | |
| 48 var programA2 = loadStandardProgram(contextA); | |
| 49 var programB = loadStandardProgram(contextB); | |
| 50 var programS = loadProgram(contextA, "resources/structUniformShader.vert", "reso
urces/fragmentShader.frag"); | |
| 51 var programV = loadProgram(contextA, "resources/floatUniformShader.vert", "resou
rces/noopUniformShader.frag"); | |
| 52 var locationA = contextA.getUniformLocation(programA1, 'u_modelViewProjMatrix'); | |
| 53 var locationB = contextB.getUniformLocation(programB, 'u_modelViewProjMatrix'); | |
| 54 var locationSx = contextA.getUniformLocation(programS, "u_struct.x"); | |
| 55 var locationArray0 = contextA.getUniformLocation(programS, "u_array[0]"); | |
| 56 var locationArray1 = contextA.getUniformLocation(programS, "u_array[1]"); | |
| 57 var locationVec4 = contextA.getUniformLocation(programV, "fval4"); | |
| 58 | |
| 59 var vec = [1, 2, 3, 4]; | |
| 60 var mat = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; | |
| 61 | |
| 62 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA
2)"); | |
| 63 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMat
rix4fv(locationA, false, mat)"); | |
| 64 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA
1)"); | |
| 65 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(lo
cationA, false, mat)"); | |
| 66 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(nu
ll, false, mat)"); | |
| 67 | |
| 68 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS
)"); | |
| 69 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationS
x, 3)"); | |
| 70 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationA
rray0, 4.0)"); | |
| 71 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationA
rray1, 5.0)"); | |
| 72 | |
| 73 shouldBe("contextA.getUniform(programS, locationSx)", "3"); | |
| 74 shouldBe("contextA.getUniform(programS, locationArray0)", "4.0"); | |
| 75 shouldBe("contextA.getUniform(programS, locationArray1)", "5.0"); | |
| 76 | |
| 77 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programV
)"); | |
| 78 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform4fv(location
Vec4, vec)"); | |
| 79 shouldBe("contextA.getUniform(programV, locationVec4)", "vec"); | |
| 80 | |
| 81 shouldBeNull("contextA.getUniformLocation(programV, \"IDontExist\")"); | |
| 82 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(program
A1)"); | |
| 83 // After linking all boxes are bad. | |
| 84 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMat
rix4fv(locationA, false, mat)"); | |
| 85 | |
| 86 // after re-linking the same program, all uniform locations become invalid. | |
| 87 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS
)"); | |
| 88 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(program
S)"); | |
| 89 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniform1i(
locationSx, 3)"); | |
| 90 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getUniform
(programS, locationSx)"); | |
| 91 | |
| 92 // Retrieve the locations again, and they should be good. | |
| 93 locationSx = contextA.getUniformLocation(programS, "u_struct.x"); | |
| 94 locationArray0 = contextA.getUniformLocation(programS, "u_array[0]"); | |
| 95 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationS
x, 3)"); | |
| 96 shouldBe("contextA.getUniform(programS, locationSx)", "3"); | |
| 97 | |
| 98 successfullyParsed = true; | |
| 99 </script> | |
| 100 | |
| 101 <script src="../resources/js-test-post.js"></script> | |
| 102 </body> | |
| 103 </html> | |
| OLD | NEW |