Examples
import { BufferType, DrawUsage, createBuffer } from '@wimaengine/render-webgl'
// `gl` is an existing WebGLRenderingContext.
const vertexBuffer = createBuffer(
gl,
BufferType.Array,
positions.byteLength,
DrawUsage.Static
)Function
createBuffer(gl: WebGLRenderingContext, type: number, size: number, bufferUsage: number): WebGLBufferAllocates a WebGL buffer for a target.
The helper calls WebGLRenderingContext#createBuffer,
asserts that WebGL returned a buffer, binds it to the supplied
BufferType with WebGLRenderingContext#bindBuffer,
and allocates size bytes with
WebGLRenderingContext#bufferData. The
DrawUsage value is passed through as WebGL’s storage-usage hint. The
newly created buffer remains bound to type when the function returns.
import { BufferType, DrawUsage, createBuffer } from '@wimaengine/render-webgl'
// `gl` is an existing WebGLRenderingContext.
const vertexBuffer = createBuffer(
gl,
BufferType.Array,
positions.byteLength,
DrawUsage.Static
)