OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 |
| 3 /* |
| 4 ** Copyright (c) 2012 The Khronos Group Inc. |
| 5 ** |
| 6 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 7 ** copy of this software and/or associated documentation files (the |
| 8 ** "Materials"), to deal in the Materials without restriction, including |
| 9 ** without limitation the rights to use, copy, modify, merge, publish, |
| 10 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 11 ** permit persons to whom the Materials are furnished to do so, subject to |
| 12 ** the following conditions: |
| 13 ** |
| 14 ** The above copyright notice and this permission notice shall be included |
| 15 ** in all copies or substantial portions of the Materials. |
| 16 ** |
| 17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 */ |
| 25 |
| 26 --> |
| 27 |
| 28 <!DOCTYPE html> |
| 29 <html> |
| 30 <head> |
| 31 <meta charset="utf-8"> |
| 32 <title>WebGL uniformMatrix Conformance Tests</title> |
| 33 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 34 <script src="../../resources/js-test-pre.js"></script> |
| 35 <script src="../resources/webgl-test.js"></script> |
| 36 </head> |
| 37 <body> |
| 38 <div id="description"></div> |
| 39 <div id="console"></div> |
| 40 <canvas id="example" width="2" height="2"> </canvas> |
| 41 |
| 42 <script id="vshader" type="x-shader/x-vertex"> |
| 43 attribute vec4 vPosition; |
| 44 uniform mat4 world4; |
| 45 uniform mat3 world3; |
| 46 uniform mat2 world2; |
| 47 void main() |
| 48 { |
| 49 gl_Position = vec4(vPosition.xyz, world3[0].x + world2[0].x) * world4; |
| 50 } |
| 51 </script> |
| 52 |
| 53 <script id="fshader" type="x-shader/x-fragment"> |
| 54 void main() |
| 55 { |
| 56 gl_FragColor = vec4(1.0,0.0,0.0,1.0); |
| 57 } |
| 58 </script> |
| 59 |
| 60 <script> |
| 61 description("This test ensures WebGL implementations handle uniformMatrix in a O
penGL ES 2.0 spec compliant way"); |
| 62 |
| 63 debug(""); |
| 64 debug("Checking gl.uniformMatrix."); |
| 65 |
| 66 gl = initWebGL("example"); |
| 67 program = setupProgram(gl, "vshader", "fshader", [ "vPosition"]); |
| 68 for (var ii = 2; ii <= 4; ++ii) { |
| 69 var loc = gl.getUniformLocation(program, "world" + ii); |
| 70 var matLess = []; |
| 71 for (var jj = 0; jj < ii; ++jj) { |
| 72 for (var ll = 0; ll < ii; ++ll) { |
| 73 if (jj == ii - 1 && ll == ii - 1) |
| 74 continue; |
| 75 matLess[jj * ii + ll] = (jj == ll) ? 1 : 0; |
| 76 } |
| 77 } |
| 78 var mat = matLess.concat([1]); |
| 79 var matMore = mat.concat([1]); |
| 80 name = "uniformMatrix" + ii + "fv"; |
| 81 gl[name](loc, false, matLess); |
| 82 glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with insufficient array siz
e for " + name); |
| 83 gl[name](loc, false, mat); |
| 84 glErrorShouldBe(gl, gl.NO_ERROR, "should succeed with correct array size for "
+ name); |
| 85 gl[name](loc, false, matMore); |
| 86 glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with more than 1 array size
for " + name); |
| 87 |
| 88 mat[ii * ii - 1] = 1; |
| 89 gl[name](loc, false, mat); |
| 90 glErrorShouldBe(gl, gl.NO_ERROR, "can call " + name + "with transpose = false"
); |
| 91 gl[name](loc, true, mat); |
| 92 glErrorShouldBe(gl, gl.INVALID_VALUE, name + " should return INVALID_VALUE wit
h transpose = true"); |
| 93 } |
| 94 |
| 95 debug(""); |
| 96 successfullyParsed = true; |
| 97 |
| 98 </script> |
| 99 <script src="../../resources/js-test-post.js"></script> |
| 100 |
| 101 </body> |
| 102 </html> |
OLD | NEW |