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 <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 </head> |
| 37 <body> |
| 38 <div id="description"></div> |
| 39 <div id="console"></div> |
| 40 |
| 41 <script> |
| 42 "use strict"; |
| 43 var wtu = WebGLTestUtils; |
| 44 description("Tests calling WebGL APIs with various types"); |
| 45 |
| 46 var context = wtu.create3DContext(); |
| 47 var program = wtu.loadStandardProgram(context); |
| 48 var shader = wtu.loadStandardVertexShader(context); |
| 49 var shouldGenerateGLError = wtu.shouldGenerateGLError; |
| 50 |
| 51 assertMsg(program != null, "Program Compiled"); |
| 52 assertMsg(shader != null, "Shader Compiled"); |
| 53 |
| 54 var loc = context.getUniformLocation(program, "u_modelViewProjMatrix"); |
| 55 assertMsg(loc != null, "getUniformLocation succeeded"); |
| 56 |
| 57 var buffer = context.createBuffer(); |
| 58 context.bindBuffer(context.ARRAY_BUFFER, buffer); |
| 59 var texture = context.createTexture(); |
| 60 context.bindTexture(context.TEXTURE_2D, texture); |
| 61 context.useProgram(program); |
| 62 |
| 63 var args = [ |
| 64 { type: "number", value: 0 }, |
| 65 { type: "number", value: 2 }, |
| 66 { type: "string that is NaN", value: "foo", }, |
| 67 { type: "string that is number", value: "2", }, |
| 68 { type: "null", value: null }, |
| 69 { type: "Empty Array", value: [] }, |
| 70 { type: "Object", value: {} }, |
| 71 { type: "Array of Number", value: [2] }, |
| 72 { type: "Array of String", value: ["foo"] }, |
| 73 { type: "Array of String that is number", value: ["0"] }, |
| 74 { type: "Array of String that is number", value: ["2"] }, |
| 75 { type: "TypedArray", value: new Float32Array(1) } |
| 76 ]; |
| 77 |
| 78 var argument; |
| 79 |
| 80 for (var i = 0; i < args.length; ++i) { |
| 81 argument = args[i].value; |
| 82 var func1 = shouldBeUndefined; |
| 83 var func2 = shouldBeNonNull; |
| 84 if (argument == 2) { |
| 85 func2 = shouldBeNull; |
| 86 } |
| 87 var func3 = shouldBeNull; |
| 88 debug(""); |
| 89 debug("testing type of " + args[i].type + " : value = " + argument); |
| 90 func1("context.bindAttribLocation(program, argument, 'foo')"); |
| 91 func1("context.blendColor(argument, argument, argument, argument)"); |
| 92 func1("context.bufferData(context.ARRAY_BUFFER, argument, context.STATIC_DRAW)
"); |
| 93 func1("context.bufferData(context.ARRAY_BUFFER, new Float32Array(10), context.
STATIC_DRAW)"); |
| 94 func1("context.bufferSubData(context.ARRAY_BUFFER, argument, new Float32Array(
2))"); |
| 95 func1("context.clear(argument)") |
| 96 func1("context.clearColor(argument, 0, 0, 0)"); |
| 97 func1("context.clearColor(0, argument, 0, 0)"); |
| 98 func1("context.clearColor(0, 0, argument, 0)"); |
| 99 func1("context.clearColor(0, 0, 0, argument)"); |
| 100 func1("context.clearDepth(argument)"); |
| 101 func1("context.clearStencil(argument)"); |
| 102 func1("context.copyTexImage2D(context.TEXTURE_2D, argument, context.RGBA, 0, 0
, 1, 1, 0)"); |
| 103 func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, argument, 0
, 1, 1, 0)"); |
| 104 func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, argument
, 1, 1, 0)"); |
| 105 func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, argum
ent, 1, 0)"); |
| 106 func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, 0, ar
gument, 0)"); |
| 107 func1("context.copyTexSubImage2D(context.TEXTURE_2D, argument, 0, 0, 0, 0, 0,
0)"); |
| 108 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, argument, 0, 0, 0, 0,
0)"); |
| 109 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, argument, 0, 0, 0,
0)"); |
| 110 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, argument, 0, 0,
0)"); |
| 111 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, argument, 0,
0)"); |
| 112 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, argument,
0)"); |
| 113 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, 0, argumen
t)"); |
| 114 func1("context.depthMask(argument)"); |
| 115 func1("context.depthRange(argument, 1)"); |
| 116 func1("context.depthRange(0, argument)"); |
| 117 func1("context.drawArrays(context.POINTS, argument, 1)"); |
| 118 func1("context.drawArrays(context.POINTS, 0, argument)"); |
| 119 //func1("context.drawElements(...)"); |
| 120 func1("context.enableVertexAttribArray(argument)"); |
| 121 func1("context.disableVertexAttribArray(argument)"); |
| 122 func2("context.getActiveAttrib(program, argument)"); |
| 123 func2("context.getActiveUniform(program, argument)"); |
| 124 func3("context.getParameter(argument)"); |
| 125 func1("context.lineWidth(argument)"); |
| 126 func1("context.polygonOffset(argument, 0)"); |
| 127 func1("context.polygonOffset(0, argument)"); |
| 128 //func1("context.readPixels(...)"); |
| 129 //func1("context.renderbufferStorage(...)"); |
| 130 func1("context.sampleCoverage(argument, 0)"); |
| 131 func1("context.sampleCoverage(0, argument)"); |
| 132 func1("context.scissor(argument, 0, 10, 10)"); |
| 133 func1("context.scissor(0, argument, 10, 10)"); |
| 134 func1("context.scissor(0, 0, argument, 10)"); |
| 135 func1("context.scissor(0, 0, 10, argument)"); |
| 136 func1("context.shaderSource(shader, argument)"); |
| 137 func1("context.stencilFunc(context.NEVER, argument, 255)"); |
| 138 func1("context.stencilFunc(context.NEVER, 0, argument)"); |
| 139 //func1("context.stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLui
nt mask)"); |
| 140 func1("context.stencilMask(argument)"); |
| 141 //func1("context.stencilMaskSeparate(context.FRONT, argument); |
| 142 //func1("context.texImage2D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayB
ufferView pixels)"); |
| 143 //func1("context.texParameterf(GLenum target, GLenum pname, GLfloat param)"); |
| 144 //func1("context.texParameteri(GLenum target, GLenum pname, GLint param)"); |
| 145 //func1("context.texSubImage2D(GLenum target, GLint level, GLint xoffset, GLin
t yoffset,GLsizei width, GLsizei height,GLenum format, GLenum type, ArrayBufferV
iew pixels)"); |
| 146 func1("context.uniform1i(loc, argument)"); |
| 147 func1("context.uniform2i(loc, argument, 0)"); |
| 148 func1("context.uniform2i(loc, 0, argument)"); |
| 149 func1("context.uniform3i(loc, argument, 0, 0)"); |
| 150 func1("context.uniform3i(loc, 0, argument, 0)"); |
| 151 func1("context.uniform3i(loc, 0, 0, argument)"); |
| 152 func1("context.uniform4i(loc, argument, 0, 0, 0)"); |
| 153 func1("context.uniform4i(loc, 0, argument, 0, 0)"); |
| 154 func1("context.uniform4i(loc, 0, 0, argument, 0)"); |
| 155 func1("context.uniform4i(loc, 0, 0, 0, argument)"); |
| 156 func1("context.uniform1f(loc, argument)"); |
| 157 func1("context.uniform2f(loc, argument, 0)"); |
| 158 func1("context.uniform2f(loc, 0, argument)"); |
| 159 func1("context.uniform3f(loc, argument, 0, 0)"); |
| 160 func1("context.uniform3f(loc, 0, argument, 0)"); |
| 161 func1("context.uniform3f(loc, 0, 0, argument)"); |
| 162 func1("context.uniform4f(loc, argument, 0, 0, 0)"); |
| 163 func1("context.uniform4f(loc, 0, argument, 0, 0)"); |
| 164 func1("context.uniform4f(loc, 0, 0, argument, 0)"); |
| 165 func1("context.uniform4f(loc, 0, 0, 0, argument)"); |
| 166 } |
| 167 |
| 168 var successfullyParsed = true; |
| 169 </script> |
| 170 |
| 171 <script src="../../resources/js-test-post.js"></script> |
| 172 </body> |
| 173 </html> |
| 174 |
OLD | NEW |