| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 Use of this source code is governed by a BSD-style license that can be | |
| 4 found in the LICENSE file. | |
| 5 --> | |
| 6 <!DOCTYPE html> | |
| 7 <html> | |
| 8 <head> | |
| 9 <meta charset="utf-8"> | |
| 10 <title>WebGL getActiveAttrib conformance test.</title> | |
| 11 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
| 12 <script src="../resources/js-test-pre.js"></script> | |
| 13 <script src="resources/webgl-test.js"> </script> | |
| 14 <script src="resources/webgl-test-utils.js"> </script> | |
| 15 </head> | |
| 16 <body> | |
| 17 <canvas id="example" width="16" height="16"></canvas> | |
| 18 <div id="description"></div> | |
| 19 <div id="console"></div> | |
| 20 <script id="vshader" type="x-shader/x-vertex"> | |
| 21 attribute $type attr0; | |
| 22 void main() | |
| 23 { | |
| 24 gl_Position = vec4(0, 0, 0, attr0$access); | |
| 25 } | |
| 26 </script> | |
| 27 <script id="fshader" type="x-shader/x-fragment"> | |
| 28 void main() | |
| 29 { | |
| 30 gl_FragColor = vec4(0,1,0,1); | |
| 31 } | |
| 32 </script> | |
| 33 <script> | |
| 34 description("Tests getActiveAttrib for various types"); | |
| 35 | |
| 36 var wtu = WebGLTestUtils; | |
| 37 var canvas = document.getElementById("example"); | |
| 38 var gl = wtu.create3DContext(canvas); | |
| 39 | |
| 40 var tests = [ | |
| 41 { glType: gl.FLOAT, size: 1, type: 'float', access: ''}, | |
| 42 { glType: gl.FLOAT_VEC2, size: 1, type: 'vec2', access: '[1]'}, | |
| 43 { glType: gl.FLOAT_VEC3, size: 1, type: 'vec3', access: '[2]'}, | |
| 44 { glType: gl.FLOAT_VEC4, size: 1, type: 'vec4', access: '[3]'}, | |
| 45 { glType: gl.FLOAT_MAT2, size: 1, type: 'mat2', access: '[1][1]'}, | |
| 46 { glType: gl.FLOAT_MAT3, size: 1, type: 'mat3', access: '[2][2]'}, | |
| 47 { glType: gl.FLOAT_MAT4, size: 1, type: 'mat4', access: '[3][3]'}, | |
| 48 ]; | |
| 49 | |
| 50 var source = document.getElementById('vshader').text; | |
| 51 var fs = wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER); | |
| 52 for (var tt = 0; tt < tests.length; ++tt) { | |
| 53 var t = tests[tt]; | |
| 54 var vs = wtu.loadShader( | |
| 55 gl, | |
| 56 source.replace('$type', t.type).replace('$access', t.access), | |
| 57 gl.VERTEX_SHADER); | |
| 58 var program = wtu.setupProgram(gl, [vs, fs]); | |
| 59 glErrorShouldBe(gl, gl.NO_ERROR, "no errors from setup"); | |
| 60 var numAttribs = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); | |
| 61 var found = false; | |
| 62 for (var ii = 0; ii < numAttribs; ++ii) { | |
| 63 var info = gl.getActiveAttrib(program, ii); | |
| 64 if (info.name == 'attr0') { | |
| 65 found = true; | |
| 66 assertMsg(info.type == t.glType, | |
| 67 "type must be " + wtu.glEnumToString(gl, t.glType) + " was " + | |
| 68 wtu.glEnumToString(gl, info.type)); | |
| 69 assertMsg(info.size == t.size, | |
| 70 "size must be " + t.size + ' was ' + info.size); | |
| 71 } | |
| 72 } | |
| 73 if (!found) { | |
| 74 testFailed("attrib 'attr0' not found"); | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 successfullyParsed = true; | |
| 79 </script> | |
| 80 <script src="../resources/js-test-post.js"></script> | |
| 81 | |
| 82 </body> | |
| 83 </html> | |
| 84 | |
| 85 | |
| OLD | NEW |