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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/webgl-conformance/conformance/limits/gl-min-textures.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     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 the minimum number of uniforms are supported.</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="4" height="4" style="width: 40px; height: 30px;"></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 vec4 vPosition;
    1.25 +void main()
    1.26 +{
    1.27 +    gl_Position = vPosition;
    1.28 +}
    1.29 +</script>
    1.30 +
    1.31 +<script id="fshader" type="x-shader/x-fragment">
    1.32 +#define NUM_TEXTURES 8 // See spec
    1.33 +precision mediump float;
    1.34 +uniform sampler2D uni[NUM_TEXTURES];
    1.35 +void main()
    1.36 +{
    1.37 +    vec4 c = vec4(0,0,0,0);
    1.38 +    for (int ii = 0; ii < NUM_TEXTURES; ++ii) {
    1.39 +      c += texture2D(uni[ii], vec2(0.5, 0.5));
    1.40 +    }
    1.41 +    gl_FragColor = c;
    1.42 +}
    1.43 +</script>
    1.44 +<script>
    1.45 +description(document.title);
    1.46 +var wtu = WebGLTestUtils;
    1.47 +var gl = wtu.create3DContext("example");
    1.48 +var program = wtu.setupTexturedQuad(gl);
    1.49 +
    1.50 +//------------------------------------------------------------------------------
    1.51 +var program = wtu.setupProgram(
    1.52 +    gl, ['vshader', 'fshader'], ['vPosition'], [0]);
    1.53 +
    1.54 +for (var ii = 0; ii < 8; ++ii) {
    1.55 +  var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
    1.56 +  gl.activeTexture(gl.TEXTURE0 + ii);
    1.57 +  var tex = gl.createTexture();
    1.58 +  wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0);
    1.59 +  gl.uniform1i(loc, ii);
    1.60 +}
    1.61 +
    1.62 +wtu.drawQuad(gl);
    1.63 +glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
    1.64 +wtu.checkCanvas(gl, [255, 128, 64, 252],
    1.65 +                "Should render using all texture units", 1);
    1.66 +
    1.67 +successfullyParsed = true;
    1.68 +
    1.69 +</script>
    1.70 +<script>finishTest();</script>
    1.71 +
    1.72 +</body>
    1.73 +</html>
    1.74 +
    1.75 +

mercurial