| OLD | NEW |
| 1 | 1 |
| 2 <!DOCTYPE html> | 2 <!DOCTYPE html> |
| 3 <html> | 3 <html> |
| 4 <head> | 4 <head> |
| 5 <meta charset="utf-8"> | 5 <meta charset="utf-8"> |
| 6 <script src="../../../resources/js-test.js"></script> | 6 <script src="../../../resources/js-test.js"></script> |
| 7 <script src="resources/webgl-test.js"></script> | 7 <script src="resources/webgl-test.js"></script> |
| 8 <script id="vshader" type="x-shader/x-vertex"> | 8 <script id="vshader" type="x-shader/x-vertex"> |
| 9 attribute vec3 pos; | 9 attribute vec3 pos; |
| 10 attribute vec4 colorIn; | 10 attribute vec4 colorIn; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 { | 136 { |
| 137 debug("Testing default attributes: { stencil:false }"); | 137 debug("Testing default attributes: { stencil:false }"); |
| 138 shouldBeNonNull("gl = getWebGL(1, 1, null, [ 0, 0, 0, 0 ], 1, 0)"); | 138 shouldBeNonNull("gl = getWebGL(1, 1, null, [ 0, 0, 0, 0 ], 1, 0)"); |
| 139 shouldBeFalse("gl.getContextAttributes().stencil"); | 139 shouldBeFalse("gl.getContextAttributes().stencil"); |
| 140 shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0"); | 140 shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0"); |
| 141 } | 141 } |
| 142 | 142 |
| 143 function testAlpha(alpha) | 143 function testAlpha(alpha) |
| 144 { | 144 { |
| 145 debug("Testing alpha = " + alpha); | 145 debug("Testing alpha = " + alpha); |
| 146 if (alpha) { | 146 if (alpha == false) { |
| 147 shouldBeNonNull("gl = getWebGL(1, 1, { alpha: true, depth: false, stenci
l: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)"); | |
| 148 shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8"); | |
| 149 } else { | |
| 150 shouldBeNonNull("gl = getWebGL(1, 1, { alpha: false, depth: false, stenc
il: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)"); | 147 shouldBeNonNull("gl = getWebGL(1, 1, { alpha: false, depth: false, stenc
il: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)"); |
| 151 shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) == 0"); | 148 shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) == 0"); |
| 149 } else { |
| 150 window.alpha = alpha; |
| 151 shouldBeNonNull("gl = getWebGL(1, 1, { alpha: alpha, depth: false, stenc
il: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)"); |
| 152 shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8"); |
| 152 } | 153 } |
| 153 shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8"); | 154 shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8"); |
| 154 shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8"); | 155 shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8"); |
| 155 shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8"); | 156 shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8"); |
| 156 shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0"); | 157 shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0"); |
| 157 shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0"); | 158 shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0"); |
| 158 | 159 |
| 159 shouldBeNonNull("contextAttribs = gl.getContextAttributes()"); | 160 shouldBeNonNull("contextAttribs = gl.getContextAttributes()"); |
| 160 shouldBeTrue("contextAttribs.alpha == " + alpha); | 161 shouldBeTrue("contextAttribs.alpha == " + (alpha || alpha == undefined || al
pha == null ? true : false)); |
| 161 | 162 |
| 162 var buf = new Uint8Array(1 * 1 * 4); | 163 var buf = new Uint8Array(1 * 1 * 4); |
| 163 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf); | 164 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf); |
| 164 pixel[0] = buf[0]; | 165 pixel[0] = buf[0]; |
| 165 pixel[1] = buf[1]; | 166 pixel[1] = buf[1]; |
| 166 pixel[2] = buf[2]; | 167 pixel[2] = buf[2]; |
| 167 pixel[3] = buf[3]; | 168 pixel[3] = buf[3]; |
| 168 correctColor = (contextAttribs.alpha ? [0, 0, 0, 0] : [0, 0, 0, 255]); | 169 correctColor = (contextAttribs.alpha ? [0, 0, 0, 0] : [0, 0, 0, 255]); |
| 169 shouldBe("pixel", "correctColor"); | 170 shouldBe("pixel", "correctColor"); |
| 170 | 171 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 var buf = drawAndReadPixel(gl, vertices, colors, 0, 0); | 332 var buf = drawAndReadPixel(gl, vertices, colors, 0, 0); |
| 332 pixel[0] = buf[0]; | 333 pixel[0] = buf[0]; |
| 333 shouldBe("pixel[0] != 255 && pixel[0] != 0", "contextAttribs.antialias"); | 334 shouldBe("pixel[0] != 255 && pixel[0] != 0", "contextAttribs.antialias"); |
| 334 } | 335 } |
| 335 | 336 |
| 336 function runTest() | 337 function runTest() |
| 337 { | 338 { |
| 338 testDefault(); | 339 testDefault(); |
| 339 testAlpha(true); | 340 testAlpha(true); |
| 340 testAlpha(false); | 341 testAlpha(false); |
| 342 testAlpha(undefined); |
| 343 testAlpha(null); |
| 341 testDepth(true); | 344 testDepth(true); |
| 342 testDepth(false); | 345 testDepth(false); |
| 343 testStencilAndDepth(true, false); | 346 testStencilAndDepth(true, false); |
| 344 testStencilAndDepth(false, false); | 347 testStencilAndDepth(false, false); |
| 345 testStencilAndDepth(true, true); | 348 testStencilAndDepth(true, true); |
| 346 testStencilAndDepth(false, true); | 349 testStencilAndDepth(false, true); |
| 347 testAntialias(true); | 350 testAntialias(true); |
| 348 testAntialias(false); | 351 testAntialias(false); |
| 349 | 352 |
| 350 finishTest(); | 353 finishTest(); |
| 351 } | 354 } |
| 352 | 355 |
| 353 </script> | 356 </script> |
| 354 </head> | 357 </head> |
| 355 <body onload="init()"> | 358 <body onload="init()"> |
| 356 <div id="description"></div> | 359 <div id="description"></div> |
| 357 <div id="console"></div> | 360 <div id="console"></div> |
| 358 </body> | 361 </body> |
| 359 </html> | 362 </html> |
| OLD | NEW |