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 |
| 46 var wtu = WebGLTestUtils; |
| 47 |
| 48 function timer() { |
| 49 if (iter == 0) { |
| 50 function init(gl) { |
| 51 gl.clearColor(1, 0, 0, 1); |
| 52 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER
_BIT); |
| 53 |
| 54 // enable scissor here, before compositing, to make sure it's correctl
y |
| 55 // ignored and restored |
| 56 gl.scissor(0, 10, 10, 10); |
| 57 gl.enable(gl.SCISSOR_TEST); |
| 58 } |
| 59 init(gl1); |
| 60 } else if (iter == 1) { |
| 61 // some random hacky stuff to make sure that we get a compositing step |
| 62 window.scrollBy(0, 10); |
| 63 window.scrollBy(0, -10); |
| 64 } else if (iter == 2) { |
| 65 function clear(gl) { |
| 66 // scissor was set earlier |
| 67 gl.clearColor(0, 0, 1, 1); |
| 68 gl.clear(gl.COLOR_BUFFER_BIT); |
| 69 |
| 70 wtu.checkCanvasRect(gl, 0, 10, 10, 10, [0, 0, 255, 255], "cleared co
rner should be blue, stencil should be preserved"); |
| 71 wtu.checkCanvasRect(gl, 0, 0, 10, 10, [0, 0, 0, 0], "remainder of bu
ffer should be cleared"); |
| 72 } |
| 73 clear(gl1); |
| 74 |
| 75 finishTest(); |
| 76 return; |
| 77 } |
| 78 |
| 79 iter++; |
| 80 setTimeout(timer, 500); |
| 81 } |
| 82 |
| 83 function go() { |
| 84 description("This test ensures WebGL implementations correctly clear the dra
wing buffer on composite if preserveDrawingBuffer is false."); |
| 85 |
| 86 debug(""); |
| 87 |
| 88 gl1 = wtu.create3DContext("c"); |
| 89 if (!gl1) { |
| 90 finishTest(); |
| 91 return; |
| 92 } |
| 93 |
| 94 shouldBeTrue("gl1 != null"); |
| 95 shouldBeTrue('gl1.getContextAttributes().preserveDrawingBuffer == false'); |
| 96 |
| 97 setTimeout(timer, 500); |
| 98 } |
| 99 |
| 100 window.addEventListener("load", go, false); |
| 101 |
| 102 successfullyParsed = true; |
| 103 </script> |
| 104 </head> |
| 105 <body> |
| 106 <!-- Important to put the canvas at the top so that it's always visible even in
the test suite runner. |
| 107 Otherwise it just doesn't get composited in Firefox. --> |
| 108 <canvas width="20" height="20" style="border: 1px solid blue;" id="c"></canvas> |
| 109 <div id="description"></div> |
| 110 <div id="console"></div> |
| 111 </body> |
| 112 </html> |
OLD | NEW |