OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../../../resources/js-test.js"></script> | |
4 <script src="resources/webgl-test.js"></script> | |
5 <script src="resources/webgl-test-utils.js"></script> | |
6 </head> | |
7 <body> | |
8 <canvas id="testbed" width="16" height="16"></canvas> | |
9 <canvas id="c" width="16" height="16"></canvas> | |
10 <div id="description"></div> | |
11 <div id="console"></div> | |
12 <script> | |
13 description('Tests texSubImage2D with bad arguments'); | |
14 | |
15 if (window.internals) | |
16 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); | |
17 | |
18 var wtu = WebGLTestUtils; | |
19 var canvas = document.getElementById("testbed"); | |
20 var c = document.getElementById("c"); | |
21 | |
22 var gl = wtu.create3DContext(canvas); | |
23 var tex = gl.createTexture(); | |
24 gl.bindTexture(gl.TEXTURE_2D, tex); | |
25 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
26 glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed"); | |
27 | |
28 // FIXME: this behavior is still being discussed on the public_webgl mailing lis
t and may | |
29 // need to be changed to throw TypeError because the argument is not nullable. | |
30 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE, null); | |
31 glErrorShouldBe(gl, gl.INVALID_VALUE, "null argument"); | |
32 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 1, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
33 glErrorShouldBe(gl, gl.INVALID_VALUE, "y + height > texture height"); | |
34 gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
35 glErrorShouldBe(gl, gl.INVALID_VALUE, "x + width > texture width"); | |
36 gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
37 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative x"); | |
38 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
39 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y"); | |
40 gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
41 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level"); | |
42 gl.texSubImage2D(gl.FLOAT, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
43 glErrorShouldBe(gl, gl.INVALID_ENUM, "bad target"); | |
44 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
45 glErrorShouldBe(gl, gl.NO_ERROR, "good args"); | |
46 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); | |
47 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original"); | |
48 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); | |
49 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original"); | |
50 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, c); | |
51 glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGB"); | |
52 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); | |
53 glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGB"); | |
54 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
55 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGB"); | |
56 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_SHORT_5_6_5, c); | |
57 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGB"); | |
58 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); | |
59 glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGBA 4_4_4_4"); | |
60 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); | |
61 glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGBA 4_4_4_4"); | |
62 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); | |
63 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGBA 4_4_
4_4"); | |
64 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); | |
65 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGBA 4_4_4_
4"); | |
66 </script> | |
67 </body> | |
68 </html> | |
OLD | NEW |