1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/programs/gl-get-active-attribute.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 1.4 +<!-- 1.5 +Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.6 +Use of this source code is governed by a BSD-style license that can be 1.7 +found in the LICENSE file. 1.8 + --> 1.9 +<!DOCTYPE html> 1.10 +<html> 1.11 +<head> 1.12 +<meta charset="utf-8"> 1.13 +<title>WebGL getActiveAttrib conformance test.</title> 1.14 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.15 +<script src="../../resources/js-test-pre.js"></script> 1.16 +<script src="../resources/webgl-test.js"> </script> 1.17 +<script src="../resources/webgl-test-utils.js"> </script> 1.18 +</head> 1.19 +<body> 1.20 +<canvas id="example" width="16" height="16"></canvas> 1.21 +<div id="description"></div> 1.22 +<div id="console"></div> 1.23 +<script id="vshader" type="x-shader/x-vertex"> 1.24 +attribute $type attr0; 1.25 +void main() 1.26 +{ 1.27 + gl_Position = vec4(0, 0, 0, attr0$access); 1.28 +} 1.29 +</script> 1.30 +<script id="fshader" type="x-shader/x-fragment"> 1.31 +void main() 1.32 +{ 1.33 + gl_FragColor = vec4(0,1,0,1); 1.34 +} 1.35 +</script> 1.36 +<script> 1.37 +description("Tests getActiveAttrib for various types"); 1.38 + 1.39 +var wtu = WebGLTestUtils; 1.40 +var gl = wtu.create3DContext("example"); 1.41 + 1.42 +var tests = [ 1.43 +{ glType: gl.FLOAT, size: 1, type: 'float', access: ''}, 1.44 +{ glType: gl.FLOAT_VEC2, size: 1, type: 'vec2', access: '[1]'}, 1.45 +{ glType: gl.FLOAT_VEC3, size: 1, type: 'vec3', access: '[2]'}, 1.46 +{ glType: gl.FLOAT_VEC4, size: 1, type: 'vec4', access: '[3]'}, 1.47 +{ glType: gl.FLOAT_MAT2, size: 1, type: 'mat2', access: '[1][1]'}, 1.48 +{ glType: gl.FLOAT_MAT3, size: 1, type: 'mat3', access: '[2][2]'}, 1.49 +{ glType: gl.FLOAT_MAT4, size: 1, type: 'mat4', access: '[3][3]'}, 1.50 +]; 1.51 + 1.52 +var source = document.getElementById('vshader').text; 1.53 +var fs = wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER); 1.54 +for (var tt = 0; tt < tests.length; ++tt) { 1.55 + var t = tests[tt]; 1.56 + var vs = wtu.loadShader( 1.57 + gl, 1.58 + source.replace('$type', t.type).replace('$access', t.access), 1.59 + gl.VERTEX_SHADER); 1.60 + var program = wtu.setupProgram(gl, [vs, fs]); 1.61 + glErrorShouldBe(gl, gl.NO_ERROR, "no errors from setup"); 1.62 + var numAttribs = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); 1.63 + var found = false; 1.64 + for (var ii = 0; ii < numAttribs; ++ii) { 1.65 + var info = gl.getActiveAttrib(program, ii); 1.66 + if (info.name == 'attr0') { 1.67 + found = true; 1.68 + assertMsg(info.type == t.glType, 1.69 + "type must be " + wtu.glEnumToString(gl, t.glType) + " was " + 1.70 + wtu.glEnumToString(gl, info.type)); 1.71 + assertMsg(info.size == t.size, 1.72 + "size must be " + t.size + ' was ' + info.size); 1.73 + } 1.74 + } 1.75 + if (!found) { 1.76 + testFailed("attrib 'attr0' not found"); 1.77 + } 1.78 +} 1.79 + 1.80 +successfullyParsed = true; 1.81 +</script> 1.82 +<script>finishTest();</script> 1.83 + 1.84 +</body> 1.85 +</html> 1.86 + 1.87 +