OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2009 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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
7 "http://www.w3.org/TR/html4/loose.dtd"> | |
8 <html> | |
9 <head> | |
10 <title>WebGL the minimum number of uniforms 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;"></c
anvas> | |
18 <div id="description"></div> | |
19 <div id="console"></div> | |
20 <script id="vshader" type="x-shader/x-vertex"> | |
21 attribute vec4 vPosition; | |
22 void main() | |
23 { | |
24 gl_Position = vPosition; | |
25 } | |
26 </script> | |
27 | |
28 <script id="fshader" type="x-shader/x-fragment"> | |
29 #define NUM_TEXTURES 8 // See spec | |
30 #ifdef GL_ES | |
31 precision mediump float; | |
32 #endif | |
33 uniform sampler2D uni[8]; | |
34 void main() | |
35 { | |
36 vec4 c = vec4(0,0,0,0); | |
37 for (int ii = 0; ii < NUM_TEXTURES; ++ii) { | |
38 c += texture2D(uni[ii], vec2(0.5, 0.5)); | |
39 } | |
40 gl_FragColor = c; | |
41 } | |
42 </script> | |
43 <script> | |
44 var wtu = WebGLTestUtils; | |
45 var canvas = document.getElementById("example"); | |
46 var gl = wtu.create3DContext(canvas); | |
47 var program = wtu.setupTexturedQuad(gl); | |
48 | |
49 //------------------------------------------------------------------------------ | |
50 var program = wtu.setupProgram( | |
51 gl, | |
52 [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER), | |
53 wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)], | |
54 ['vPosition'], [0]); | |
55 | |
56 for (var ii = 0; ii < 8; ++ii) { | |
57 var loc = gl.getUniformLocation(program, "uni[" + ii + "]"); | |
58 gl.activeTexture(gl.TEXTURE0 + ii); | |
59 var tex = gl.createTexture(); | |
60 wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0); | |
61 gl.uniform1i(loc, ii); | |
62 } | |
63 | |
64 wtu.drawQuad(gl); | |
65 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup."); | |
66 wtu.checkCanvas(gl, [255, 128, 64, 252], | |
67 "Should render using all texture units"); | |
68 | |
69 successfullyParsed = true; | |
70 | |
71 </script> | |
72 </body> | |
73 <script src="../resources/js-test-post.js"></script> | |
74 | |
75 <script> | |
76 </script> | |
77 | |
78 </body> | |
79 </html> | |
80 | |
81 | |
OLD | NEW |