Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: conformance/textures/texture-formats-test.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « conformance/textures/texture-complete.html ('k') | conformance/textures/texture-mips.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <title>WebGL Texture Format Conformance Tests</title>
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
12 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></s cript>
13 <script src="../../debug/webgl-debug.js" type="text/javascript"></script>
14 <script src="../../resources/js-test-pre.js"></script>
15 <script src="../resources/webgl-test.js"></script>
16 <script src="../resources/webgl-test-utils.js"></script>
17 </head>
18 <body>
19 <div id="description"></div>
20 <div id="console"></div>
21 <canvas id="canvas2d" width="2" height="2" style="width: 50px; height: 50px; bor der: 1px solid black;"></canvas>
22 <canvas id="canvas" width="2" height="2" style="width: 100px; height:100px; bord er: 1px solid black;"> </canvas>
23 <script>
24 description("This test ensures WebGL implementations allow the OpenGL ES 2.0 tex ture formats and do not allow DesktopGL texture formats.");
25
26 debug("");
27 debug("Canvas.getContext");
28
29 var wtu = WebGLTestUtils;
30 var gl = wtu.create3DContext(document.getElementById("canvas"));
31 if (!gl) {
32 testFailed("context does not exist");
33 } else {
34 testPassed("context exists");
35 if ("WebGLDebugUtils" in window)
36 WebGLDebugUtils.init(gl);
37 else
38 WebGLDebugUtils = false;
39
40 debug("");
41 debug("Checking texture formats.");
42
43 function createTexture(internalFormat, format, opt_border) {
44 var border = (opt_border === undefined) ? 0 : opt_border;
45 var tex = gl.createTexture();
46 gl.bindTexture(gl.TEXTURE_2D, tex);
47 gl.texImage2D(gl.TEXTURE_2D,
48 0, // level
49 internalFormat, // internalFormat
50 16, // width
51 16, // height
52 border, // border
53 format, // format
54 gl.UNSIGNED_BYTE, // type
55 null); // data
56 }
57
58 function testValidFormat(internalFormat, formatName) {
59 createTexture(internalFormat, internalFormat);
60 glErrorShouldBe(gl, gl.NO_ERROR,
61 "was able to create texture of " + formatName);
62 }
63
64 function testInvalidFormat(internalFormat, formatName) {
65 createTexture(internalFormat, internalFormat);
66 var err = gl.getError();
67 if (err == gl.NO_ERROR) {
68 testFailed("should NOT be able to create texture of type " + formatNam e);
69 } else if (err == gl.INVALID_OPERATION) {
70 testFailed("should return gl.INVALID_ENUM for type " + formatName);
71 } else if (err == gl.INVALID_ENUM) {
72 testPassed("not able to create invalid format: " + formatName);
73 }
74 }
75
76 var invalidEnums = [
77 '1',
78 '2',
79 '3',
80 '4',
81 'RGB4',
82 'RGB5',
83 'RGB8',
84 'RGB10',
85 'RGB12',
86 'RGB16',
87 'RGBA2',
88 'RGBA4',
89 'RGB5_A1',
90 'RGBA8',
91 'RGB10_A2',
92 'RGBA12',
93 'RGBA16',
94 'BGR',
95 'BGRA',
96 'ALPHA4_EXT',
97 'ALPHA8_EXT',
98 'ALPHA12_EXT',
99 'ALPHA16_EXT',
100 'COMPRESSED_ALPHA',
101 'COMPRESSED_LUMINANCE',
102 'COMPRESSED_LUMINANCE_ALPHA',
103 'COMPRESSED_INTENSITY',
104 'COMPRESSED_RGB',
105 'COMPRESSED_RGBA',
106 'DEPTH_COMPONENT16',
107 'DEPTH_COMPONENT24',
108 'DEPTH_COMPONENT32',
109 'LUMINANCE4_EXT',
110 'LUMINANCE8_EXT',
111 'LUMINANCE12_EXT',
112 'LUMINANCE16_EXT',
113 'LUMINANCE4_ALPHA4_EXT',
114 'LUMINANCE6_ALPHA2_EXT',
115 'LUMINANCE8_ALPHA8_EXT',
116 'LUMINANCE12_ALPHA4_EXT',
117 'LUMINANCE12_ALPHA12_EXT',
118 'LUMINANCE16_ALPHA16_EXT',
119 'INTENSITY_EXT',
120 'INTENSITY4_EXT',
121 'INTENSITY8_EXT',
122 'INTENSITY12_EXT',
123 'INTENSITY16_EXT',
124 'RGB4_EXT',
125 'RGB5_EXT',
126 'RGB8_EXT',
127 'RGB10_EXT',
128 'RGB12_EXT',
129 'RGB16_EXT',
130 'RGBA2_EXT',
131 'RGBA4_EXT',
132 'RGB5_A1_EXT',
133 'RGBA8_EXT',
134 'RGB10_A2_EXT',
135 'RGBA12_EXT',
136 'RGBA16_EXT',
137 'SLUMINANCE_EXT',
138 'SLUMINANCE8_EXT',
139 'SLUMINANCE_ALPHA_EXT',
140 'SLUMINANCE8_ALPHA8_EXT',
141 'SRGB_EXT',
142 'SRGB8_EXT',
143 'SRGB_ALPHA_EXT',
144 'SRGB8_ALPHA8'
145 ];
146
147 for (var ii = 0; ii < invalidEnums.length; ++ii) {
148 var formatName = invalidEnums[ii]
149 if (desktopGL[formatName] === undefined) {
150 debug("bad format" + formatName)
151 } else {
152 testInvalidFormat(desktopGL[formatName], "GL_" + formatName);
153 }
154 }
155
156 var validEnums = [
157 'ALPHA',
158 'RGB',
159 'RGBA',
160 'LUMINANCE',
161 'LUMINANCE_ALPHA'
162 ];
163
164 for (var ii = 0; ii < validEnums.length; ++ii) {
165 var formatName = validEnums[ii]
166 testValidFormat(gl[formatName], "gl." + formatName);
167 }
168
169 debug("");
170 debug("checking non 0 border parameter to gl.TexImage2D");
171 createTexture(gl['RGBA'], gl['RGBA'], 1);
172 glErrorShouldBe(gl, gl.INVALID_VALUE,
173 "non 0 border to gl.TexImage2D should return INVALID_VALUE");
174
175
176 function checkTypes() {
177 var canvas = document.getElementById("canvas");
178 gl = wtu.create3DContext(canvas);
179 var program = wtu.setupTexturedQuad(gl);
180
181 gl.disable(gl.DEPTH_TEST);
182 gl.disable(gl.BLEND);
183
184 var tex = gl.createTexture();
185 gl.bindTexture(gl.TEXTURE_2D, tex);
186 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
187 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
188 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
189
190 var loc = gl.getUniformLocation(program, "tex");
191 gl.uniform1i(loc, 0);
192
193 function checkType(r, g, b, a, type, format, buf) {
194 var typeName = WebGLDebugUtils ? WebGLDebugUtils.glEnumToString(type) : ty pe;
195 debug("");
196 debug("checking gl.texImage2D with type: " + typeName);
197 gl.texImage2D(gl.TEXTURE_2D,
198 0, // level
199 format, // internalFormat
200 2, // width
201 2, // height
202 0, // border
203 format, // format
204 type, // type
205 buf); // data
206
207 glErrorShouldBe(gl, gl.NO_ERROR,
208 "gl.texImage2D with " + typeName + " should generate NO_ERROR");
209
210 wtu.drawQuad(gl, [255, 0, 0, 255]);
211 wtu.checkCanvas(gl, [r,g,b,a],
212 "texture type " + typeName + " should draw with " +
213 r + ", " + g + ", " + b + ", " + a);
214
215 }
216 checkType(0, 255, 0, 255, gl.UNSIGNED_BYTE, gl.RGBA,
217 new Uint8Array([
218 0, 255, 0, 255,
219 0, 255, 0, 255,
220 0, 255, 0, 255,
221 0, 255, 0, 255]));
222 checkType(0, 0, 255, 255, gl.UNSIGNED_SHORT_4_4_4_4, gl.RGBA,
223 new Uint16Array([
224 255, 255,
225 255, 255,
226 255, 255,
227 255, 255]));
228 checkType(0, 255, 0, 255, gl.UNSIGNED_SHORT_5_6_5, gl.RGB,
229 new Uint16Array([
230 2016, 2016,
231 2016, 2016,
232 2016, 2016,
233 2016, 2016]));
234 checkType(0, 0, 255, 255, gl.UNSIGNED_SHORT_5_5_5_1, gl.RGBA,
235 new Uint16Array([
236 63, 63,
237 63, 63,
238 63, 63,
239 63, 63]));
240 }
241 checkTypes();
242 }
243
244 debug("");
245 successfullyParsed = true;
246
247 </script>
248 <script src="../../resources/js-test-post.js"></script>
249
250 </body>
251 </html>
OLDNEW
« no previous file with comments | « conformance/textures/texture-complete.html ('k') | conformance/textures/texture-mips.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698