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 |
| 28 <!DOCTYPE html> |
| 29 <html> |
| 30 <head> |
| 31 <meta charset="utf-8"> |
| 32 <title>WebGL gl calls Conformance Tests</title> |
| 33 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 34 <script src="../../resources/js-test-pre.js"></script> |
| 35 <script src="../resources/webgl-test.js"></script> |
| 36 </head> |
| 37 <body> |
| 38 <div id="description"></div> |
| 39 <div id="console"></div> |
| 40 <canvas id="canvas" width="2" height="2"> </canvas> |
| 41 |
| 42 <script> |
| 43 |
| 44 description("This test ensures basic functionality of the underlying graphics li
brary"); |
| 45 |
| 46 debug(""); |
| 47 debug("Canvas.getContext"); |
| 48 |
| 49 var minimumRequiredStencilMask = 0; |
| 50 var context = create3DContext(document.getElementById("canvas")); |
| 51 if (!context) |
| 52 testFailed("context does not exist"); |
| 53 else { |
| 54 testPassed("context exists"); |
| 55 |
| 56 debug(""); |
| 57 debug("Context contains getError"); |
| 58 if ("getError" in context) |
| 59 testPassed("context contains getError"); |
| 60 else |
| 61 testFailed("context does not contains getError"); |
| 62 |
| 63 debug(""); |
| 64 debug("Check default values"); |
| 65 shouldBe('context.getParameter(context.ACTIVE_TEXTURE)', 'context.TEXTURE0')
; |
| 66 shouldBe('(context.getParameter(context.ALIASED_LINE_WIDTH_RANGE)[0] <= 1) &
& (context.getParameter(context.ALIASED_LINE_WIDTH_RANGE)[0] > 0) && (context.ge
tParameter(context.ALIASED_LINE_WIDTH_RANGE)[1] >= 1)', 'true'); |
| 67 shouldBe('(context.getParameter(context.ALIASED_POINT_SIZE_RANGE)[0] <= 1) &
& (context.getParameter(context.ALIASED_POINT_SIZE_RANGE)[0] > 0) && (context.ge
tParameter(context.ALIASED_POINT_SIZE_RANGE)[1] >= 1)', 'true'); |
| 68 shouldBeType('(context.getParameter(context.ALIASED_LINE_WIDTH_RANGE)',
'Float32Array'); |
| 69 shouldBeType('(context.getParameter(context.ALIASED_POINT_SIZE_RANGE)',
'Float32Array'); |
| 70 shouldBe('context.getParameter(context.ARRAY_BUFFER_BINDING)', 'null'); |
| 71 shouldBe('context.getParameter(context.BLEND)', 'false'); |
| 72 shouldBe('context.getParameter(context.BLEND_COLOR)', '[0, 0, 0, 0]'); |
| 73 shouldBeType('context.getParameter(context.BLEND_COLOR)', 'Float32Array'
); |
| 74 shouldBe('context.getParameter(context.BLEND_DST_ALPHA)', '0'); |
| 75 shouldBe('context.getParameter(context.BLEND_DST_RGB)', '0'); |
| 76 shouldBe('context.getParameter(context.BLEND_EQUATION_ALPHA)', 'context.FUNC
_ADD'); |
| 77 shouldBe('context.getParameter(context.BLEND_EQUATION_RGB)', 'context.FUNC_A
DD'); |
| 78 shouldBe('context.getParameter(context.BLEND_SRC_ALPHA)', '1'); |
| 79 shouldBe('context.getParameter(context.BLEND_SRC_RGB)', '1'); |
| 80 shouldBe('context.getParameter(context.COLOR_CLEAR_VALUE)', '[0, 0, 0, 0]'); |
| 81 shouldBeType('context.getParameter(context.COLOR_CLEAR_VALUE)', 'Float32
Array'); |
| 82 shouldBe('context.getParameter(context.COLOR_WRITEMASK)', '[true, true, true
, true]'); |
| 83 shouldBeType('context.getParameter(context.COMPRESSED_TEXTURE_FORMATS)',
'Uint32Array'); |
| 84 shouldBe('context.getParameter(context.CULL_FACE)', 'false'); |
| 85 shouldBe('context.getParameter(context.CULL_FACE_MODE)', 'context.BACK'); |
| 86 shouldBe('context.getParameter(context.CURRENT_PROGRAM)', 'null'); |
| 87 shouldBe('context.getParameter(context.DEPTH_CLEAR_VALUE)', '1'); |
| 88 shouldBe('context.getParameter(context.DEPTH_FUNC)', 'context.LESS'); |
| 89 shouldBe('context.getParameter(context.DEPTH_RANGE)', '[0, 1]'); |
| 90 shouldBeType('context.getParameter(context.DEPTH_RANGE)', 'Float32Array'
); |
| 91 shouldBe('context.getParameter(context.DEPTH_TEST)', 'false'); |
| 92 shouldBe('context.getParameter(context.DEPTH_WRITEMASK)', 'true'); |
| 93 shouldBe('context.getParameter(context.DITHER)', 'true'); |
| 94 shouldBe('context.getParameter(context.ELEMENT_ARRAY_BUFFER_BINDING)', 'null
'); |
| 95 shouldBe('context.getParameter(context.FRONT_FACE)', 'context.CCW'); |
| 96 shouldBe('context.getParameter(context.GENERATE_MIPMAP_HINT)', 'context.DONT
_CARE'); |
| 97 shouldBe('context.getParameter(context.LINE_WIDTH)', '1'); |
| 98 shouldBe('context.getParameter(context.POLYGON_OFFSET_FACTOR)', '0'); |
| 99 shouldBe('context.getParameter(context.POLYGON_OFFSET_FILL)', 'false'); |
| 100 shouldBe('context.getParameter(context.POLYGON_OFFSET_UNITS)', '0'); |
| 101 shouldBe('context.getParameter(context.RENDERBUFFER_BINDING)', 'null'); |
| 102 shouldBe('context.getParameter(context.SAMPLE_COVERAGE_INVERT)', 'false'); |
| 103 shouldBe('context.getParameter(context.SAMPLE_COVERAGE_VALUE)', '1'); |
| 104 shouldBe('context.getParameter(context.SCISSOR_BOX)[0]', '0'); |
| 105 shouldBe('context.getParameter(context.SCISSOR_BOX)[1]', '0'); |
| 106 shouldBeType('context.getParameter(context.SCISSOR_BOX)', Int32Array); |
| 107 shouldBe('context.getParameter(context.SCISSOR_TEST)', 'false'); |
| 108 shouldBe('context.getParameter(context.STENCIL_BACK_FAIL)', 'context.KEEP'); |
| 109 shouldBe('context.getParameter(context.STENCIL_BACK_FUNC)', 'context.ALWAYS'
); |
| 110 shouldBe('context.getParameter(context.STENCIL_BACK_PASS_DEPTH_FAIL)', 'cont
ext.KEEP'); |
| 111 shouldBe('context.getParameter(context.STENCIL_BACK_PASS_DEPTH_PASS)', 'cont
ext.KEEP'); |
| 112 shouldBe('context.getParameter(context.STENCIL_BACK_REF)', '0'); |
| 113 |
| 114 var stencilBits = context.getParameter(context.STENCIL_BITS); |
| 115 minimumRequiredStencilMask = (1 << stencilBits) - 1; |
| 116 |
| 117 shouldBe('context.getParameter(context.STENCIL_BACK_VALUE_MASK) & minimumReq
uiredStencilMask', 'minimumRequiredStencilMask'); |
| 118 shouldBe('context.getParameter(context.STENCIL_BACK_WRITEMASK) & minimumRequ
iredStencilMask', 'minimumRequiredStencilMask'); |
| 119 |
| 120 // If EXT_packed_depth_stencil is supported, STENCIL_BITS > 0; otherwise, ST
ENCIL_BITS == 0. |
| 121 shouldBe('context.getParameter(context.STENCIL_BITS) >= 0', 'true'); |
| 122 shouldBe('context.getParameter(context.STENCIL_CLEAR_VALUE)', '0'); |
| 123 shouldBe('context.getParameter(context.STENCIL_FAIL)', 'context.KEEP'); |
| 124 shouldBe('context.getParameter(context.STENCIL_FUNC)', 'context.ALWAYS'); |
| 125 shouldBe('context.getParameter(context.STENCIL_PASS_DEPTH_FAIL)', 'context.K
EEP'); |
| 126 shouldBe('context.getParameter(context.STENCIL_PASS_DEPTH_PASS)', 'context.K
EEP'); |
| 127 shouldBe('context.getParameter(context.STENCIL_REF)', '0'); |
| 128 shouldBe('context.getParameter(context.STENCIL_TEST)', 'false'); |
| 129 |
| 130 shouldBe('context.getParameter(context.STENCIL_VALUE_MASK) & minimumRequired
StencilMask', 'minimumRequiredStencilMask'); |
| 131 shouldBe('context.getParameter(context.STENCIL_WRITEMASK) & minimumRequiredS
tencilMask', 'minimumRequiredStencilMask'); |
| 132 |
| 133 shouldBe('context.getParameter(context.TEXTURE_BINDING_2D)', 'null'); |
| 134 shouldBe('context.getParameter(context.TEXTURE_BINDING_CUBE_MAP)', 'null'); |
| 135 shouldBe('context.getParameter(context.UNPACK_ALIGNMENT)', '4'); |
| 136 shouldBe('context.getParameter(context.UNPACK_FLIP_Y_WEBGL)', 'false'); |
| 137 shouldBe('context.getParameter(context.UNPACK_PREMULTIPLY_ALPHA_WEBGL)', 'fa
lse'); |
| 138 shouldBe('context.getParameter(context.VIEWPORT)', '[0, 0, 2, 2]'); |
| 139 shouldBeType('context.getParameter(context.VIEWPORT)', 'Int32Array'); |
| 140 |
| 141 shouldBeTrue('context.getParameter(context.MAX_COMBINED_TEXTURE_IMAGE_UNITS)
>= 8'); |
| 142 shouldBeTrue('context.getParameter(context.MAX_CUBE_MAP_TEXTURE_SIZE) >= 16'
); |
| 143 shouldBeTrue('context.getParameter(context.MAX_FRAGMENT_UNIFORM_VECTORS) >=
16'); |
| 144 shouldBeTrue('context.getParameter(context.MAX_RENDERBUFFER_SIZE) >= 1'); |
| 145 shouldBeTrue('context.getParameter(context.MAX_TEXTURE_IMAGE_UNITS) >= 8'); |
| 146 shouldBeTrue('context.getParameter(context.MAX_TEXTURE_SIZE) >= 64'); |
| 147 shouldBeTrue('context.getParameter(context.MAX_VARYING_VECTORS) >= 8'); |
| 148 shouldBeTrue('context.getParameter(context.MAX_VERTEX_ATTRIBS) >= 8'); |
| 149 shouldBeTrue('context.getParameter(context.MAX_VERTEX_TEXTURE_IMAGE_UNITS) >
= 0'); |
| 150 shouldBeTrue('context.getParameter(context.MAX_VERTEX_UNIFORM_VECTORS) >= 12
8'); |
| 151 // Note: This requirement should be removed from the spec IMO. Many impeleme
ntations |
| 152 // will be based on FBOs and FBOs might have a restriction smaller than the
current screen size. |
| 153 // especially if there are multiple screens. |
| 154 shouldBeTrue('context.getParameter(context.MAX_VIEWPORT_DIMS)[0] >= window.s
creen.width'); |
| 155 shouldBeTrue('context.getParameter(context.MAX_VIEWPORT_DIMS)[1] >= window.s
creen.height'); |
| 156 shouldBeType('context.getParameter(context.MAX_VIEWPORT_DIMS)', 'Int32Ar
ray'); |
| 157 |
| 158 debug(""); |
| 159 debug("check texture values"); |
| 160 var maxTextures = context.getParameter(context.MAX_TEXTURE_IMAGE_UNITS); |
| 161 for (var ii = 0; ii < maxTextures; ++ii) { |
| 162 context.activeTexture(context.TEXTURE0 + ii); |
| 163 debug("check texture unit: " + ii); |
| 164 shouldBe('context.getParameter(context.TEXTURE_BINDING_2D)', 'null'); |
| 165 shouldBe('context.getParameter(context.TEXTURE_BINDING_CUBE_MAP)', 'null')
; |
| 166 } |
| 167 |
| 168 debug(""); |
| 169 debug("check attrib values"); |
| 170 var maxAttribs = context.getParameter(context.MAX_VERTEX_ATTRIBS); |
| 171 for (var ii = 0; ii < maxAttribs; ++ii) { |
| 172 debug("check attrib: " + ii); |
| 173 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_BUFFER_B
INDING)', 'null'); |
| 174 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_ENABLED)
', 'false'); |
| 175 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_SIZE)',
'4'); |
| 176 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_STRIDE)'
, '0'); |
| 177 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_TYPE)',
'context.FLOAT'); |
| 178 shouldBe('context.getVertexAttrib(ii, context.VERTEX_ATTRIB_ARRAY_NORMALIZ
ED)', 'false'); |
| 179 shouldBe('context.getVertexAttrib(ii, context.CURRENT_VERTEX_ATTRIB)', '[0
, 0, 0, 1]'); |
| 180 shouldBeType('context.getVertexAttrib(ii, context.CURRENT_VERTEX_ATTRI
B)', 'Float32Array'); |
| 181 shouldBe('context.getVertexAttribOffset(ii, context.VERTEX_ATTRIB_ARRAY_PO
INTER)', '0'); |
| 182 } |
| 183 |
| 184 shouldBe('context.getError()', 'context.NO_ERROR'); |
| 185 } |
| 186 |
| 187 debug(""); |
| 188 successfullyParsed = true; |
| 189 |
| 190 </script> |
| 191 <script src="../../resources/js-test-post.js"></script> |
| 192 |
| 193 </body> |
| 194 </html> |
OLD | NEW |