1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/conformance/textures/tex-sub-image-2d-bad-args.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<head> 1.7 +<meta charset="utf-8"> 1.8 +<link rel="stylesheet" href="../../resources/js-test-style.css"/> 1.9 +<script src="../../resources/js-test-pre.js"></script> 1.10 +<script src="../resources/webgl-test.js"></script> 1.11 +<script src="../resources/webgl-test-utils.js"></script> 1.12 +</head> 1.13 +<body> 1.14 +<canvas id="testbed" width="16" height="16"></canvas> 1.15 +<canvas id="c" width="16" height="16"></canvas> 1.16 +<div id="description"></div> 1.17 +<div id="console"></div> 1.18 +<script> 1.19 +description('Tests texSubImage2D with bad arguments'); 1.20 + 1.21 +var wtu = WebGLTestUtils; 1.22 +var c = document.getElementById("c"); 1.23 + 1.24 +var gl = wtu.create3DContext("testbed"); 1.25 +var tex = gl.createTexture(); 1.26 +gl.bindTexture(gl.TEXTURE_2D, tex); 1.27 +gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.28 +glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed"); 1.29 + 1.30 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 1, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.31 +glErrorShouldBe(gl, gl.INVALID_VALUE, "y + height > texture height"); 1.32 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.33 +glErrorShouldBe(gl, gl.INVALID_VALUE, "x + width > texture width"); 1.34 +gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.35 +glErrorShouldBe(gl, gl.INVALID_VALUE, "negative x"); 1.36 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.37 +glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y"); 1.38 +gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.39 +glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level"); 1.40 +gl.texSubImage2D(gl.FLOAT, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.41 +glErrorShouldBe(gl, gl.INVALID_ENUM, "bad target"); 1.42 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.43 +glErrorShouldBe(gl, gl.NO_ERROR, "good args"); 1.44 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); 1.45 +glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original"); 1.46 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); 1.47 +glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original"); 1.48 +gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, c); 1.49 +glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGB"); 1.50 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); 1.51 +glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGB"); 1.52 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.53 +glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGB"); 1.54 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_SHORT_5_6_5, c); 1.55 +glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGB"); 1.56 +gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); 1.57 +glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGBA 4_4_4_4"); 1.58 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); 1.59 +glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGBA 4_4_4_4"); 1.60 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); 1.61 +glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGBA 4_4_4_4"); 1.62 +gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); 1.63 +glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGBA 4_4_4_4"); 1.64 + 1.65 +successfullyParsed = true; 1.66 +</script> 1.67 +<script>finishTest();</script> 1.68 +</body> 1.69 +</html>