OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 |
| 3 /* |
| 4 ** Copyright (c) 2012 The Khronos Group Inc. |
| 5 ** |
| 6 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 7 ** copy of this software and/or associated documentation files (the |
| 8 ** "Materials"), to deal in the Materials without restriction, including |
| 9 ** without limitation the rights to use, copy, modify, merge, publish, |
| 10 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 11 ** permit persons to whom the Materials are furnished to do so, subject to |
| 12 ** the following conditions: |
| 13 ** |
| 14 ** The above copyright notice and this permission notice shall be included |
| 15 ** in all copies or substantial portions of the Materials. |
| 16 ** |
| 17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 */ |
| 25 |
| 26 --> |
| 27 <!DOCTYPE html> |
| 28 <html> |
| 29 <head> |
| 30 <meta charset="utf-8"> |
| 31 <title>WebGL required buffer clear behaviour test</title> |
| 32 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 33 <script src="../../resources/js-test-pre.js"></script> |
| 34 <script src="../resources/webgl-test.js"> </script> |
| 35 <script src="../resources/webgl-test-utils.js"> </script> |
| 36 <style type="text/css"> |
| 37 body { |
| 38 height: 3000px; |
| 39 } |
| 40 </style> |
| 41 <script type="text/javascript"> |
| 42 |
| 43 var iter = 0; |
| 44 var gl1; |
| 45 var gl2; |
| 46 |
| 47 var wtu = WebGLTestUtils; |
| 48 |
| 49 function timer() { |
| 50 if (iter == 0) { |
| 51 // some random hacky stuff to make sure that we get a compositing step |
| 52 window.scrollBy(0, 10); |
| 53 window.scrollBy(0, -10); |
| 54 iter++; |
| 55 |
| 56 setTimeout(timer, 500); |
| 57 } else if (iter == 1) { |
| 58 function clear(gl) { |
| 59 // scissor was set earlier |
| 60 gl.clearColor(0, 0, 1, 1); |
| 61 gl.clear(gl.COLOR_BUFFER_BIT); |
| 62 } |
| 63 clear(gl1); |
| 64 clear(gl2); |
| 65 |
| 66 debug("check on screen canvas"); |
| 67 wtu.checkCanvasRect(gl1, 0, 10, 10, 10, [0, 0, 255, 255], "cleared corne
r should be blue, stencil should be preserved"); |
| 68 wtu.checkCanvasRect(gl1, 0, 0, 10, 10, [0, 0, 0, 0], "remainder of buffe
r should be cleared"); |
| 69 debug("check off screen canvas"); |
| 70 wtu.checkCanvasRect(gl2, 0, 10, 10, 10, [0, 0, 255, 255], "cleared corne
r should be blue, stencil should be preserved"); |
| 71 wtu.checkCanvasRect(gl2, 0, 0, 10, 10, [255, 0, 0, 255], "remainder of b
uffer should be un-cleared red"); |
| 72 |
| 73 finishTest(); |
| 74 } |
| 75 } |
| 76 |
| 77 function go() { |
| 78 description("This test ensures WebGL implementations correctly clear the dra
wing buffer on composite if preserveDrawingBuffer is false."); |
| 79 |
| 80 debug(""); |
| 81 |
| 82 gl1 = wtu.create3DContext("c"); |
| 83 gl2 = create3DContext(); |
| 84 shouldBeTrue("gl1 != null"); |
| 85 shouldBeTrue("gl2 != null"); |
| 86 |
| 87 shouldBeTrue('gl1.getContextAttributes().preserveDrawingBuffer == false'); |
| 88 shouldBeTrue('gl2.getContextAttributes().preserveDrawingBuffer == false'); |
| 89 |
| 90 function init(gl) { |
| 91 gl.clearColor(1, 0, 0, 1); |
| 92 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_B
IT); |
| 93 |
| 94 // enable scissor here, before compositing, to make sure it's correctly |
| 95 // ignored and restored |
| 96 gl.scissor(0, 10, 10, 10); |
| 97 gl.enable(gl.SCISSOR_TEST); |
| 98 } |
| 99 |
| 100 init(gl1); |
| 101 init(gl2); |
| 102 |
| 103 setTimeout(timer, 500); |
| 104 } |
| 105 |
| 106 window.addEventListener("load", go, false); |
| 107 |
| 108 successfullyParsed = true; |
| 109 </script> |
| 110 </head> |
| 111 <body> |
| 112 <div id="description"></div> |
| 113 <canvas width="20" height="20" style="border: 1px solid blue;" id="c"></canvas> |
| 114 <div id="console"></div> |
| 115 </body> |
| 116 </html> |
| 117 |
OLD | NEW |