content/canvas/test/webgl-conformance/conformance/textures/tex-sub-image-2d-bad-args.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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');
    18 var wtu = WebGLTestUtils;
    19 var c = document.getElementById("c");
    21 var gl = wtu.create3DContext("testbed");
    22 var tex = gl.createTexture();
    23 gl.bindTexture(gl.TEXTURE_2D, tex);
    24 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c);
    25 glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed"); 
    27 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 1, gl.RGBA, gl.UNSIGNED_BYTE, c);
    28 glErrorShouldBe(gl, gl.INVALID_VALUE, "y + height > texture height");
    29 gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
    30 glErrorShouldBe(gl, gl.INVALID_VALUE, "x + width > texture width");
    31 gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
    32 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative x");
    33 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, c);
    34 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y");
    35 gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
    36 glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level");
    37 gl.texSubImage2D(gl.FLOAT, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
    38 glErrorShouldBe(gl, gl.INVALID_ENUM, "bad target");
    39 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
    40 glErrorShouldBe(gl, gl.NO_ERROR, "good args");
    41 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
    42 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original");
    43 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
    44 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original");
    45 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, c);
    46 glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGB");
    47 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
    48 glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGB");
    49 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
    50 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGB");
    51 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_SHORT_5_6_5, c);
    52 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGB");
    53 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
    54 glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGBA 4_4_4_4");
    55 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
    56 glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGBA 4_4_4_4");
    57 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
    58 glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGBA 4_4_4_4");
    59 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
    60 glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGBA 4_4_4_4");
    62 successfullyParsed = true;
    63 </script>
    64 <script>finishTest();</script>
    65 </body>
    66 </html>

mercurial