OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (C) 2011 Apple Computer, Inc. All rights reserved. | |
3 | |
4 Redistribution and use in source and binary forms, with or without | |
5 modification, are permitted provided that the following conditions | |
6 are met: | |
7 1. Redistributions of source code must retain the above copyright | |
8 notice, this list of conditions and the following disclaimer. | |
9 2. Redistributions in binary form must reproduce the above copyright | |
10 notice, this list of conditions and the following disclaimer in the | |
11 documentation and/or other materials provided with the distribution. | |
12 | |
13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 --> | |
25 <!DOCTYPE html> | |
26 <html> | |
27 <head> | |
28 <meta charset="utf-8"> | |
29 <link rel="stylesheet" href="../resources/js-test-style.css"/> | |
30 <script src="../resources/js-test-pre.js"></script> | |
31 <script src="resources/webgl-test.js"></script> | |
32 <script src="resources/webgl-test-utils.js"></script> | |
33 </head> | |
34 <body> | |
35 <div id="description"></div> | |
36 <div id="console"></div> | |
37 | |
38 <script> | |
39 var wtu = WebGLTestUtils; | |
40 description("Tests calling WebGL APIs with various types"); | |
41 | |
42 var context = wtu.create3DContext(); | |
43 var program = wtu.loadStandardProgram(context); | |
44 var shader = wtu.loadStandardVertexShader(context); | |
45 var shouldGenerateGLError = wtu.shouldGenerateGLError; | |
46 | |
47 assertMsg(program != null, "Program Compiled"); | |
48 assertMsg(shader != null, "Shader Compiled"); | |
49 | |
50 var loc = context.getUniformLocation(program, "u_modelViewProjMatrix"); | |
51 assertMsg(loc != null, "getUniformLocation succeeded"); | |
52 | |
53 var buffer = context.createBuffer(); | |
54 context.bindBuffer(context.ARRAY_BUFFER, buffer); | |
55 var texture = context.createTexture(); | |
56 context.bindTexture(context.TEXTURE_2D, texture); | |
57 context.useProgram(program); | |
58 | |
59 var args = [ | |
60 { type: "number", value: 0 }, | |
61 { type: "number", value: 2 }, | |
62 { type: "string that is NaN", value: "foo", }, | |
63 { type: "string that is number", value: "2", }, | |
64 { type: "null", value: null }, | |
65 { type: "Empty Array", value: [] }, | |
66 { type: "Object", value: {} }, | |
67 { type: "Array of Number", value: [2] }, | |
68 { type: "Array of String", value: ["foo"] }, | |
69 { type: "Array of String that is number", value: ["0"] }, | |
70 { type: "Array of String that is number", value: ["2"] }, | |
71 { type: "TypedArray", value: new Float32Array(1) } | |
72 ]; | |
73 | |
74 var argument; | |
75 | |
76 for (var i = 0; i < args.length; ++i) { | |
77 argument = args[i].value; | |
78 var func1 = shouldBeUndefined; | |
79 var func2 = shouldBeNonNull; | |
80 if (argument == 2) { | |
81 func2 = shouldBeNull; | |
82 } | |
83 func3 = shouldBeNull; | |
84 debug(""); | |
85 debug("testing type of " + args[i].type + " : value = " + argument); | |
86 func1("context.bindAttribLocation(program, argument, 'foo')"); | |
87 func1("context.blendColor(argument, argument, argument, argument)"); | |
88 func1("context.bufferData(context.ARRAY_BUFFER, argument, context.STATIC_DRAW)
"); | |
89 func1("context.bufferData(context.ARRAY_BUFFER, new Float32Array(10), context.
STATIC_DRAW)"); | |
90 func1("context.bufferSubData(context.ARRAY_BUFFER, argument, new Float32Array(
2))"); | |
91 func1("context.clear(argument)") | |
92 func1("context.clearColor(argument, 0, 0, 0)"); | |
93 func1("context.clearColor(0, argument, 0, 0)"); | |
94 func1("context.clearColor(0, 0, argument, 0)"); | |
95 func1("context.clearColor(0, 0, 0, argument)"); | |
96 func1("context.clearDepth(argument)"); | |
97 func1("context.clearStencil(argument)"); | |
98 func1("context.copyTexImage2D(context.TEXTURE_2D, argument, context.RGBA, 0, 0
, 1, 1, 0)"); | |
99 func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, argument, 0
, 1, 1, 0)"); | |
100 func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, argument
, 1, 1, 0)"); | |
101 func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, argum
ent, 1, 0)"); | |
102 func1("context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, 0, ar
gument, 0)"); | |
103 func1("context.copyTexSubImage2D(context.TEXTURE_2D, argument, 0, 0, 0, 0, 0,
0)"); | |
104 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, argument, 0, 0, 0, 0,
0)"); | |
105 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, argument, 0, 0, 0,
0)"); | |
106 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, argument, 0, 0,
0)"); | |
107 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, argument, 0,
0)"); | |
108 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, argument,
0)"); | |
109 func1("context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, 0, argumen
t)"); | |
110 func1("context.depthMask(argument)"); | |
111 func1("context.depthRange(argument, 1)"); | |
112 func1("context.depthRange(0, argument)"); | |
113 func1("context.drawArrays(context.POINTS, argument, 1)"); | |
114 func1("context.drawArrays(context.POINTS, 0, argument)"); | |
115 //func1("context.drawElements(...)"); | |
116 func1("context.enableVertexAttribArray(argument)"); | |
117 func1("context.disableVertexAttribArray(argument)"); | |
118 func2("context.getActiveAttrib(program, argument)"); | |
119 func2("context.getActiveUniform(program, argument)"); | |
120 func3("context.getParameter(argument)"); | |
121 func1("context.lineWidth(argument)"); | |
122 func1("context.polygonOffset(argument, 0)"); | |
123 func1("context.polygonOffset(0, argument)"); | |
124 //func1("context.readPixels(...)"); | |
125 //func1("context.renderbufferStorage(...)"); | |
126 func1("context.sampleCoverage(argument, 0)"); | |
127 func1("context.sampleCoverage(0, argument)"); | |
128 func1("context.scissor(argument, 0, 10, 10)"); | |
129 func1("context.scissor(0, argument, 10, 10)"); | |
130 func1("context.scissor(0, 0, argument, 10)"); | |
131 func1("context.scissor(0, 0, 10, argument)"); | |
132 func1("context.shaderSource(shader, argument)"); | |
133 func1("context.stencilFunc(context.NEVER, argument, 255)"); | |
134 func1("context.stencilFunc(context.NEVER, 0, argument)"); | |
135 //func1("context.stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLui
nt mask)"); | |
136 func1("context.stencilMask(argument)"); | |
137 //func1("context.stencilMaskSeparate(context.FRONT, argument); | |
138 //func1("context.texImage2D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayB
ufferView pixels)"); | |
139 //func1("context.texParameterf(GLenum target, GLenum pname, GLfloat param)"); | |
140 //func1("context.texParameteri(GLenum target, GLenum pname, GLint param)"); | |
141 //func1("context.texSubImage2D(GLenum target, GLint level, GLint xoffset, GLin
t yoffset,GLsizei width, GLsizei height,GLenum format, GLenum type, ArrayBufferV
iew pixels)"); | |
142 func1("context.uniform1i(loc, argument)"); | |
143 func1("context.uniform2i(loc, argument, 0)"); | |
144 func1("context.uniform2i(loc, 0, argument)"); | |
145 func1("context.uniform3i(loc, argument, 0, 0)"); | |
146 func1("context.uniform3i(loc, 0, argument, 0)"); | |
147 func1("context.uniform3i(loc, 0, 0, argument)"); | |
148 func1("context.uniform4i(loc, argument, 0, 0, 0)"); | |
149 func1("context.uniform4i(loc, 0, argument, 0, 0)"); | |
150 func1("context.uniform4i(loc, 0, 0, argument, 0)"); | |
151 func1("context.uniform4i(loc, 0, 0, 0, argument)"); | |
152 func1("context.uniform1f(loc, argument)"); | |
153 func1("context.uniform2f(loc, argument, 0)"); | |
154 func1("context.uniform2f(loc, 0, argument)"); | |
155 func1("context.uniform3f(loc, argument, 0, 0)"); | |
156 func1("context.uniform3f(loc, 0, argument, 0)"); | |
157 func1("context.uniform3f(loc, 0, 0, argument)"); | |
158 func1("context.uniform4f(loc, argument, 0, 0, 0)"); | |
159 func1("context.uniform4f(loc, 0, argument, 0, 0)"); | |
160 func1("context.uniform4f(loc, 0, 0, argument, 0)"); | |
161 func1("context.uniform4f(loc, 0, 0, 0, argument)"); | |
162 } | |
163 | |
164 successfullyParsed = true; | |
165 </script> | |
166 | |
167 <script src="../resources/js-test-post.js"></script> | |
168 </body> | |
169 </html> | |
170 | |
OLD | NEW |