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, buf, ebuf) { |
| 20 var data = [0,0,0,0, 1,0,0,0, 0,1,0,0]; |
| 21 gl.bufferData(gl.ARRAY_BUFFER, 12, gl.STATIC_DRAW); |
| 22 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([]), gl.STATIC_DRAW); |
| 23 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(data), gl.STATIC_DRAW); |
| 24 assertEquals(gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE), 12*4); |
| 25 assertEquals(gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE), gl.STA
TIC_DRAW); |
| 26 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(data), gl.STREAM_DRAW); |
| 27 assertEquals(gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE), 12*4); |
| 28 assertEquals(gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE), gl.STR
EAM_DRAW); |
| 29 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(data), gl.DYNAMIC_DRAW); |
| 30 assertEquals(gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE), 12*4); |
| 31 assertEquals(gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE), gl.DYN
AMIC_DRAW); |
| 32 |
| 33 gl.bufferData(gl.ARRAY_BUFFER, new Uint16Array(data), gl.STATIC_DRAW); |
| 34 gl.bufferData(gl.ARRAY_BUFFER, new Uint16Array(data), gl.STREAM_DRAW); |
| 35 gl.bufferData(gl.ARRAY_BUFFER, new Uint16Array(data), gl.DYNAMIC_DRAW); |
| 36 assertEquals(gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE), 12*2); |
| 37 throwError(gl, "array bufferSubData"); |
| 38 } |
| 39 Tests.testBufferDataElement = function(gl, buf, ebuf) { |
| 40 var data = [0,0,0,0, 1,0,0,0, 0,1,0,0]; |
| 41 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(data), gl.STATIC_DRAW
); |
| 42 assertEquals(gl.getBufferParameter(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_USAGE)
, gl.STATIC_DRAW); |
| 43 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(data), gl.STREAM_DRAW
); |
| 44 assertEquals(gl.getBufferParameter(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_USAGE)
, gl.STREAM_DRAW); |
| 45 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(data), gl.DYNAMIC_DRA
W); |
| 46 assertEquals(gl.getBufferParameter(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_USAGE)
, gl.DYNAMIC_DRAW); |
| 47 assertEquals(gl.getBufferParameter(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_SIZE),
12*2); |
| 48 throwError(gl, "element array bufferSubData"); |
| 49 } |
| 50 |
| 51 Tests.endUnit = function(gl, buf, ebuf) { |
| 52 gl.deleteBuffer(buf); |
| 53 gl.deleteBuffer(ebuf); |
| 54 } |
| 55 |
| 56 </script> |
| 57 <style>canvas{ position:absolute; }</style> |
| 58 </head><body> |
| 59 <canvas id="gl" width="16" height="16"></canvas> |
| 60 </body></html> |
OLD | NEW |