content/canvas/test/webgl-conformance/conformance/glsl/variables/gl-frontfacing.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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>gl-fragcoord Test</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="32" height="32">
    18 </canvas>
    19 <div id="description"></div>
    20 <div id="console"></div>
    21   <script id="vshader" type="x-shader/x-vertex">
    22     attribute vec4 vPosition;
    23     void main()
    24     {
    25       gl_Position = vPosition;
    26     }
    27   </script>
    29   <script id="fshader" type="x-shader/x-fragment">
    30     precision mediump float;
    31     void main()
    32     {
    33       gl_FragColor = vec4(
    34         gl_FrontFacing ? 1.0 : 0.0,
    35         gl_FrontFacing ? 0.0 : 1.0,
    36         0,
    37         1);
    38     }
    39   </script>
    41   <script>
    42     function init()
    43     {
    44       if (window.initNonKhronosFramework) {
    45         window.initNonKhronosFramework(false);
    46       }
    48       description("tests gl_FrontFacing");
    50       wtu = WebGLTestUtils;
    51       gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
    53       var gridRes = 4;
    54       wtu.setupQuad(gl, gridRes, 0, true);
    56       gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
    57       gl.drawElements(gl.TRIANGLES, gridRes * gridRes * 6, gl.UNSIGNED_SHORT, 0);
    58       wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw");
    60       var step = 32 / gridRes;
    61       var halfStep = step / 2;
    62       var quarterStep = halfStep / 2;
    63       for (var xx = 0; xx < 32; xx += step) {
    64         for (var yy = 0; yy < 32; yy += step) {
    65           for (var ii = 0; ii < 2; ++ii) {
    66             var color = [
    67               ii == 0 ? 255 : 0,
    68               ii == 0 ? 0 : 255,
    69               0
    70             ];
    71             var msg = "should be " + color;
    72             wtu.checkCanvasRect(
    73                 gl, 
    74                 xx + quarterStep + halfStep * ii, 
    75                 yy + quarterStep + halfStep * ii, 
    76                 1, 1, color, msg, 4);
    77           }
    78         }
    79       }
    80     }
    82     init();
    83     successfullyParsed = true;
    84   </script>
    85 <script>finishTest();</script>
    87 </body>
    88 </html>

mercurial