OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html><head> |
| 3 <meta charset="utf-8"> |
| 4 <link rel="stylesheet" type="text/css" href="../unit.css" /> |
| 5 <script type="application/x-javascript" src="../unit.js"></script> |
| 6 <script type="application/x-javascript" src="../util.js"></script> |
| 7 <script type="application/x-javascript"> |
| 8 |
| 9 Tests.startUnit = function () { |
| 10 var canvas = document.getElementById('gl'); |
| 11 var gl = wrapGLContext(canvas.getContext(GL_CONTEXT_ID)); |
| 12 var tex = gl.createTexture(); |
| 13 gl.bindTexture(gl.TEXTURE_2D, tex); |
| 14 return [gl, tex]; |
| 15 } |
| 16 |
| 17 Tests.testTexImage2D = function(gl) { |
| 18 var b = document.createElement('b'); |
| 19 var div = document.createElement('div'); |
| 20 var c = document.getElementById('c'); |
| 21 assertFail("bad element b", |
| 22 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNE
D_BYTE, b); }); |
| 23 assertFail("bad element div", |
| 24 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNE
D_BYTE, div); }); |
| 25 assertFail("no element", |
| 26 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNE
D_BYTE, 0); }); |
| 27 assertFail("string as data", |
| 28 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNE
D_BYTE, "foo"); }); |
| 29 assertOk("canvas as data", |
| 30 function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGN
ED_BYTE, c); }); |
| 31 assertFail("bad target", |
| 32 function() {gl.texImage2D(gl.FLOAT, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYT
E, c); }); |
| 33 } |
| 34 |
| 35 Tests.endUnit = function(gl, tex) { |
| 36 gl.bindTexture(gl.TEXTURE_2D, null); |
| 37 gl.deleteTexture(tex); |
| 38 } |
| 39 |
| 40 </script> |
| 41 <style>canvas{ position:absolute; }</style> |
| 42 </head><body> |
| 43 <canvas id="gl" width="16" height="16"></canvas> |
| 44 <canvas id="c" width="16" height="16"></canvas> |
| 45 </body></html> |
OLD | NEW |