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 Disabled Vertex Attrib Test</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 <script src="../resources/webgl-test-utils.js"> </script> |
| 37 </head> |
| 38 <body> |
| 39 <canvas id="example" width="50" height="50"> |
| 40 </canvas> |
| 41 <div id="description"></div> |
| 42 <div id="console"></div> |
| 43 <script id="vshader" type="x-shader/x-vertex"> |
| 44 attribute vec4 a_position; |
| 45 attribute vec4 a_color; |
| 46 varying vec4 v_color; |
| 47 void main() { |
| 48 gl_Position = a_position; |
| 49 v_color = a_color; |
| 50 } |
| 51 </script> |
| 52 |
| 53 <script id="fshader" type="x-shader/x-fragment"> |
| 54 precision mediump float; |
| 55 varying vec4 v_color; |
| 56 bool isCorrectColor(vec4 v) { |
| 57 return v.x == 0.0 && v.y == 0.0 && v.z == 0.0 && v.w == 1.0; |
| 58 } |
| 59 void main() { |
| 60 gl_FragColor = isCorrectColor(v_color) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1); |
| 61 } |
| 62 </script> |
| 63 |
| 64 <script> |
| 65 var wtu = WebGLTestUtils; |
| 66 description(); |
| 67 |
| 68 gl = wtu.create3DContext("example"); |
| 69 |
| 70 var numVertexAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); |
| 71 for (var ii = 0; ii < numVertexAttribs; ++ii) { |
| 72 var colorLocation = (ii + 1) % numVertexAttribs; |
| 73 var positionLocation = colorLocation ? 0 : 1; |
| 74 |
| 75 if (positionLocation != 0) { |
| 76 // We need to create a new 3d context for testing attrib 0 |
| 77 // since we've already effected attrib 0 on other tests. |
| 78 gl = wtu.create3DContext(); |
| 79 } |
| 80 |
| 81 debug("testing attrib: " + colorLocation); |
| 82 var program = wtu.setupProgram( |
| 83 gl, |
| 84 ['vshader', 'fshader'], |
| 85 ['a_position', 'a_color'], |
| 86 [positionLocation, colorLocation]); |
| 87 var gridRes = 1; |
| 88 wtu.setupQuad(gl, gridRes, positionLocation); |
| 89 wtu.drawIndexedQuad(gl, gridRes); |
| 90 wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green"); |
| 91 } |
| 92 glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors"); |
| 93 |
| 94 successfullyParsed = true; |
| 95 </script> |
| 96 <script src="../../resources/js-test-post.js"></script> |
| 97 |
| 98 </body> |
| 99 </html> |
| 100 |
OLD | NEW |