vertexAttribPointerBadArgs.html (2642B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <!-- 6 Copyright (c) 2019 The Khronos Group Inc. 7 Use of this source code is governed by an MIT-style license that can be 8 found in the LICENSE.txt file. 9 --> 10 <link rel="stylesheet" type="text/css" href="../unit.css" /> 11 <script type="application/javascript" src="../unit.js"></script> 12 <script type="application/javascript" src="../util.js"></script> 13 <script type="application/javascript"> 14 15 Tests.startUnit = function () { 16 var canvas = document.createElement('canvas'); 17 var gl = wrapGLContext(getGLContext(canvas)); 18 return [gl]; 19 } 20 21 Tests.setup = function(gl) { 22 assert(0 == gl.getError()); 23 return [gl]; 24 } 25 26 Tests.teardown = function(gl) { 27 } 28 29 Tests.endUnit = function(gl) { 30 } 31 32 Tests.testVertexAttribPointerVBO = function(gl) { 33 var vbo = gl.createBuffer(); 34 gl.bindBuffer(gl.ARRAY_BUFFER, vbo); 35 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(4), gl.STATIC_DRAW); 36 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); 37 assertFail("negative offset", 38 function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, -4);}); 39 assertOk("out of range offset (OK because we can change the buffer later)", 40 function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 1200);}); 41 assertFail("Offset that is incompatible with type", 42 function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 3);}); 43 assertFail("negative stride", 44 function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, -1, 0);}); 45 assertFail("bad size", 46 function(){gl.vertexAttribPointer(0, 5, gl.FLOAT, false, 0, 0);}); 47 assertFail("stride that doesn't match type", 48 function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 1, 0);}); 49 assertFail("bad type", 50 function(){gl.vertexAttribPointer(0, 3, gl.TEXTURE_2D, false, 0, 0);}); 51 assertFail("bad index", 52 function(){gl.vertexAttribPointer(-1, 3, gl.FLOAT, false, 0, 0);}); 53 assertFail("bad index (big negative)", 54 function(){gl.vertexAttribPointer(-8693948, 3, gl.FLOAT, false, 0, 0);}); 55 assertFail("bad index (big positive)", 56 function(){gl.vertexAttribPointer(8693948, 3, gl.FLOAT, false, 0, 0);}); 57 gl.bindBuffer(gl.ARRAY_BUFFER, null); 58 assertOk("binding to null buffer with offset=0", 59 function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);}); 60 assertFail("binding to null buffer with offset!=0", 61 function(){gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 16);}); 62 gl.bindBuffer(gl.ARRAY_BUFFER, vbo); 63 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); 64 gl.bindBuffer(gl.ARRAY_BUFFER, null); 65 gl.deleteBuffer(vbo); 66 throwError(gl); 67 } 68 69 </script> 70 </head><body> 71 </body></html>