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 buf = gl.createBuffer(); |
| 13 var ebuf = gl.createBuffer(); |
| 14 gl.bindBuffer(gl.ARRAY_BUFFER, buf); |
| 15 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ebuf); |
| 16 return [gl, buf, ebuf]; |
| 17 } |
| 18 |
| 19 Tests.testBufferData = function(gl) { |
| 20 assertOk("zero size data", |
| 21 function(){gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(0), gl.STATIC
_DRAW);}); |
| 22 assertFail("bad target", |
| 23 function(){gl.bufferData(gl.TEXTURE_2D, new Float32Array([1,2,3]), gl.ST
ATIC_DRAW);}); |
| 24 // assertFail("array for data", |
| 25 // function(){gl.bufferData(gl.ARRAY_BUFFER, [1,2,3], gl.STATIC_DRAW);}); |
| 26 assertFail("bad usage", |
| 27 function(){gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1,2,3]), gl.
TEXTURE_2D);}); |
| 28 assertOk(function(){gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Float32Array(
[1,2,3]), gl.STATIC_DRAW);}); |
| 29 throwError(gl, 'bufferData'); |
| 30 gl.bindBuffer(gl.ARRAY_BUFFER, null); |
| 31 assertFail(function(){gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1,2,3
]), gl.STATIC_DRAW);}); |
| 32 throwError(gl, 'bufferData'); |
| 33 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); |
| 34 assertFail(function(){gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array
([1,2,3]), gl.STATIC_DRAW);}); |
| 35 throwError(gl, 'bufferData'); |
| 36 } |
| 37 |
| 38 Tests.endUnit = function(gl, buf, ebuf) { |
| 39 gl.deleteBuffer(buf); |
| 40 gl.deleteBuffer(ebuf); |
| 41 } |
| 42 |
| 43 |
| 44 </script> |
| 45 <style>canvas{ position:absolute; }</style> |
| 46 </head><body> |
| 47 <canvas id="gl" width="16" height="16"></canvas> |
| 48 </body></html> |
OLD | NEW |