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 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 precision mediump float; |
| 31 uniform sampler2D uni[8]; |
| 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 var wtu = WebGLTestUtils; |
| 43 var canvas = document.getElementById("example"); |
| 44 var gl = wtu.create3DContext(canvas); |
| 45 var program = wtu.setupTexturedQuad(gl); |
| 46 |
| 47 //------------------------------------------------------------------------------ |
| 48 var program = wtu.setupProgram( |
| 49 gl, |
| 50 [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER), |
| 51 wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)], |
| 52 ['vPosition'], [0]); |
| 53 |
| 54 for (var ii = 0; ii < 8; ++ii) { |
| 55 var loc = gl.getUniformLocation(program, "uni[" + ii + "]"); |
| 56 gl.activeTexture(gl.TEXTURE0 + ii); |
| 57 var tex = gl.createTexture(); |
| 58 wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0); |
| 59 gl.uniform1i(loc, ii); |
| 60 } |
| 61 |
| 62 wtu.drawQuad(gl); |
| 63 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup."); |
| 64 wtu.checkCanvas(gl, [255, 128, 64, 252], |
| 65 "Should render using all texture units"); |
| 66 |
| 67 successfullyParsed = true; |
| 68 |
| 69 </script> |
| 70 <script src="../../resources/js-test-post.js"></script> |
| 71 |
| 72 </body> |
| 73 </html> |
| 74 |
| 75 |
OLD | NEW |