OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 6 <script src="../../resources/js-test-pre.js"></script> |
| 7 <script src="../resources/webgl-test.js"></script> |
| 8 <script src="../resources/webgl-test-utils.js"></script> |
| 9 </head> |
| 10 <body> |
| 11 <canvas id="testbed" width="16" height="16"></canvas> |
| 12 <canvas id="c" width="16" height="16"></canvas> |
| 13 <div id="description"></div> |
| 14 <div id="console"></div> |
| 15 <script> |
| 16 description('Tests texSubImage2D with bad arguments'); |
| 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 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 1, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 29 glErrorShouldBe(gl, gl.INVALID_VALUE, "y + height > texture height"); |
| 30 gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 31 glErrorShouldBe(gl, gl.INVALID_VALUE, "x + width > texture width"); |
| 32 gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 33 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative x"); |
| 34 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 35 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y"); |
| 36 gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 37 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level"); |
| 38 gl.texSubImage2D(gl.FLOAT, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 39 glErrorShouldBe(gl, gl.INVALID_ENUM, "bad target"); |
| 40 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 41 glErrorShouldBe(gl, gl.NO_ERROR, "good args"); |
| 42 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); |
| 43 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original"); |
| 44 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); |
| 45 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original"); |
| 46 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, c); |
| 47 glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGB"); |
| 48 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); |
| 49 glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGB"); |
| 50 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 51 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGB"); |
| 52 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_SHORT_5_6_5, c); |
| 53 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGB"); |
| 54 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); |
| 55 glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGBA 4_4_4_4"); |
| 56 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); |
| 57 glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGBA 4_4_4_4"); |
| 58 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); |
| 59 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGBA 4_4_
4_4"); |
| 60 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); |
| 61 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGBA 4_4_4_
4"); |
| 62 |
| 63 successfullyParsed = true; |
| 64 </script> |
| 65 <script src="../../resources/js-test-post.js"></script> |
| 66 </body> |
| 67 </html> |
OLD | NEW |