Skip to content

Lower level

createBuffer() ​

ts
function createBuffer(
   gl, 
   data, 
   usage?, 
   type?
): WebGLBuffer;

Defined in: createBuffer.js:13

Creates a buffer and uploads data to it. The buffer is left bound to type.

Parameters ​

ParameterTypeDefault valueDescription
glWebGL2RenderingContextundefinedThe WebGL2 context.
dataArrayBufferView<ArrayBufferLike>undefinedThe contents.
usage?numbergl.STATIC_DRAWHow it will be used, e.g. gl.DYNAMIC_DRAW. Defaults to gl.STATIC_DRAW.
type?numbergl.ARRAY_BUFFERThe target to bind it to. Defaults to gl.ARRAY_BUFFER.

Returns ​

WebGLBuffer