1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/glsl/variables/gl-frontfacing.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 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>gl-fragcoord Test</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="32" height="32"> 1.21 +</canvas> 1.22 +<div id="description"></div> 1.23 +<div id="console"></div> 1.24 + <script id="vshader" type="x-shader/x-vertex"> 1.25 + attribute vec4 vPosition; 1.26 + void main() 1.27 + { 1.28 + gl_Position = vPosition; 1.29 + } 1.30 + </script> 1.31 + 1.32 + <script id="fshader" type="x-shader/x-fragment"> 1.33 + precision mediump float; 1.34 + void main() 1.35 + { 1.36 + gl_FragColor = vec4( 1.37 + gl_FrontFacing ? 1.0 : 0.0, 1.38 + gl_FrontFacing ? 0.0 : 1.0, 1.39 + 0, 1.40 + 1); 1.41 + } 1.42 + </script> 1.43 + 1.44 + <script> 1.45 + function init() 1.46 + { 1.47 + if (window.initNonKhronosFramework) { 1.48 + window.initNonKhronosFramework(false); 1.49 + } 1.50 + 1.51 + description("tests gl_FrontFacing"); 1.52 + 1.53 + wtu = WebGLTestUtils; 1.54 + gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1); 1.55 + 1.56 + var gridRes = 4; 1.57 + wtu.setupQuad(gl, gridRes, 0, true); 1.58 + 1.59 + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 1.60 + gl.drawElements(gl.TRIANGLES, gridRes * gridRes * 6, gl.UNSIGNED_SHORT, 0); 1.61 + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw"); 1.62 + 1.63 + var step = 32 / gridRes; 1.64 + var halfStep = step / 2; 1.65 + var quarterStep = halfStep / 2; 1.66 + for (var xx = 0; xx < 32; xx += step) { 1.67 + for (var yy = 0; yy < 32; yy += step) { 1.68 + for (var ii = 0; ii < 2; ++ii) { 1.69 + var color = [ 1.70 + ii == 0 ? 255 : 0, 1.71 + ii == 0 ? 0 : 255, 1.72 + 0 1.73 + ]; 1.74 + var msg = "should be " + color; 1.75 + wtu.checkCanvasRect( 1.76 + gl, 1.77 + xx + quarterStep + halfStep * ii, 1.78 + yy + quarterStep + halfStep * ii, 1.79 + 1, 1, color, msg, 4); 1.80 + } 1.81 + } 1.82 + } 1.83 + } 1.84 + 1.85 + init(); 1.86 + successfullyParsed = true; 1.87 + </script> 1.88 +<script>finishTest();</script> 1.89 + 1.90 +</body> 1.91 +</html>