content/canvas/test/webgl-conformance/conformance/limits/gl-min-attribs.html

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:237a1741fdfc
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 the minimum number of attributes are supported.</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="4" height="4" style="width: 40px; height: 30px;"></canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="vshader" type="x-shader/x-vertex">
21 attribute vec4 vPosition;
22 attribute vec4 v0;
23 attribute vec4 v1;
24 attribute vec4 v2;
25 attribute vec4 v3;
26 attribute vec4 v4;
27 attribute vec4 v5;
28 attribute vec4 v6;
29 varying vec4 color;
30 void main()
31 {
32 gl_Position = vPosition;
33 color = v0 + v1 + v2 + v3 + v4 + v5 + v6;
34 }
35 </script>
36
37 <script id="fshader" type="x-shader/x-fragment">
38 precision mediump float;
39 varying vec4 color;
40 void main()
41 {
42 gl_FragColor = color;
43 }
44 </script>
45 <script>
46 description(document.title);
47 var wtu = WebGLTestUtils;
48 var gl = wtu.create3DContext("example");
49 var program = wtu.setupTexturedQuad(gl);
50
51 var program = wtu.setupProgram(
52 gl,
53 ['vshader', 'fshader'],
54 ['vPosition', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5', 'v6'],
55 [0, 1, 2, 3, 4, 5, 6, 7]);
56
57 for (var ii = 0; ii < 7; ++ii) {
58 var v = (ii + 1) / 28;
59 var vertexObject = gl.createBuffer();
60 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
61 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
62 v, v/2, v/4, v/8,
63 v, v/2, v/4, v/8,
64 v, v/2, v/4, v/8,
65 v, v/2, v/4, v/8,
66 v, v/2, v/4, v/8,
67 v, v/2, v/4, v/8]), gl.STATIC_DRAW);
68 gl.enableVertexAttribArray(ii + 1);
69 gl.vertexAttribPointer(ii + 1, 4, gl.FLOAT, false, 0, 0);
70 }
71
72 wtu.drawQuad(gl);
73 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
74 wtu.checkCanvasRect(gl, 0, 0, gl.canvas.width, gl.canvas.height, [255, 127, 64, 32], "Should render 255,127,64,32 (+/-1)", 1);
75
76 successfullyParsed = true;
77
78 </script>
79 </body>
80 <script>finishTest();</script>
81
82 </body>
83 </html>
84
85

mercurial