1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/rendering/gl-scissor-test.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 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 Scissor Test</title> 1.14 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.15 +<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script> 1.16 +<script src="../../debug/webgl-debug.js"></script> 1.17 +<script src="../../resources/js-test-pre.js"></script> 1.18 +<script src="../resources/webgl-test-utils.js"></script> 1.19 +</head> 1.20 +<body> 1.21 +<div id="description"></div> 1.22 +<div id="console"></div> 1.23 +<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"> </canvas> 1.24 +<script> 1.25 +description("Check if glScissor setting works."); 1.26 + 1.27 +debug(""); 1.28 +debug("Canvas.getContext"); 1.29 + 1.30 +var wtu = WebGLTestUtils; 1.31 +var gl = wtu.create3DContext(document.getElementById("canvas")); 1.32 +if (!gl) { 1.33 + testFailed("context does not exist"); 1.34 +} else { 1.35 + testPassed("context exists"); 1.36 + 1.37 + debug(""); 1.38 + 1.39 + gl.clearColor(0,0,0,0); 1.40 + gl.clear(gl.COLOR_BUFFER_BIT); 1.41 + 1.42 + // clear a portion of our FBO 1.43 + gl.enable(gl.SCISSOR_TEST); 1.44 + gl.scissor(0, 0, 1, 1); 1.45 + gl.clearColor(0,1,0,1); 1.46 + gl.clear(gl.COLOR_BUFFER_BIT); 1.47 + 1.48 + var b = new Uint8Array(2 * 2 * 4); 1.49 + gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, b); 1.50 + 1.51 + function checkPixel(b, x, y, color) { 1.52 + var offset = (y * 2 + x) * 4; 1.53 + var match = true; 1.54 + for (var c = 0; c < 4; ++c) { 1.55 + if (b[offset + c] != color[c] * 255) { 1.56 + match = false; 1.57 + break; 1.58 + } 1.59 + } 1.60 + assertMsg(match, "pixel at " + x + ", " + y + " is expected value"); 1.61 + } 1.62 + 1.63 + checkPixel(b, 0, 0, [0, 1, 0, 1]); 1.64 + checkPixel(b, 1, 0, [0, 0, 0, 0]); 1.65 + checkPixel(b, 0, 1, [0, 0, 0, 0]); 1.66 + checkPixel(b, 1, 1, [0, 0, 0, 0]); 1.67 +} 1.68 + 1.69 +debug(""); 1.70 +successfullyParsed = true; 1.71 + 1.72 +</script> 1.73 +<script>finishTest();</script> 1.74 + 1.75 +</body> 1.76 +</html>