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

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     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>
    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);
    47 //------------------------------------------------------------------------------
    48 var program = wtu.setupProgram(
    49     gl, ['vshader', 'fshader'], ['vPosition'], [0]);
    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 }
    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);
    64 successfullyParsed = true;
    66 </script>
    67 <script>finishTest();</script>
    69 </body>
    70 </html>

mercurial