|
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 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;"></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 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 precision mediump float; |
|
31 uniform sampler2D uni[NUM_TEXTURES]; |
|
32 void main() |
|
33 { |
|
34 vec4 c = vec4(0,0,0,0); |
|
35 for (int ii = 0; ii < NUM_TEXTURES; ++ii) { |
|
36 c += texture2D(uni[ii], vec2(0.5, 0.5)); |
|
37 } |
|
38 gl_FragColor = c; |
|
39 } |
|
40 </script> |
|
41 <script> |
|
42 description(document.title); |
|
43 var wtu = WebGLTestUtils; |
|
44 var gl = wtu.create3DContext("example"); |
|
45 var program = wtu.setupTexturedQuad(gl); |
|
46 |
|
47 //------------------------------------------------------------------------------ |
|
48 var program = wtu.setupProgram( |
|
49 gl, ['vshader', 'fshader'], ['vPosition'], [0]); |
|
50 |
|
51 for (var ii = 0; ii < 8; ++ii) { |
|
52 var loc = gl.getUniformLocation(program, "uni[" + ii + "]"); |
|
53 gl.activeTexture(gl.TEXTURE0 + ii); |
|
54 var tex = gl.createTexture(); |
|
55 wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0); |
|
56 gl.uniform1i(loc, ii); |
|
57 } |
|
58 |
|
59 wtu.drawQuad(gl); |
|
60 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup."); |
|
61 wtu.checkCanvas(gl, [255, 128, 64, 252], |
|
62 "Should render using all texture units", 1); |
|
63 |
|
64 successfullyParsed = true; |
|
65 |
|
66 </script> |
|
67 <script>finishTest();</script> |
|
68 |
|
69 </body> |
|
70 </html> |
|
71 |
|
72 |