IndexBuffer

IndexBuffer

new IndexBuffer(gl, typeopt, dataopt, usageopt)

Parameters:
Name Type Attributes Default Description
gl WebGLRenderingContext then webgl context this ArrayBuffer belongs to
type GLenum <optional>
GL_UNSIGNED_SHORT the inetger type of the indices (GL_UNSIGNED_BYTE, GL_UNSIGNED_INT etc)
data TypedArray | uint <optional>
optional data to copy to buffer, or the size (in bytes)
usage GLenum <optional>
GL_STATIC_DRAW the usage hint for this buffer.
Implements:
Source:

Methods

bind()

Bind the underlying webgl buffer.
Source:

data(array)

Fill webgl buffer with the given data. You can also pass a uint to allocate the buffer to the given size.
Parameters:
Name Type Description
array TypedArray | uint the data to send to the buffer, or a size.
Source:

dispose()

Delete underlying webgl objects
Source:

draw(mode, countopt, offsetopt)

Shortcut to gl.drawArrays
Parameters:
Name Type Attributes Default Description
mode GLenum the type of primitive to draw (GL_TRIANGLE, GL_POINTS etc)
count uint <optional>
the number of indices to draw (full buffer is used if omited)
offset uint <optional>
0 the position of the first index to draw
Source:

subData(array, offset)

Set a part of the buffer with the given data, starting a offset (in bytes)
Parameters:
Name Type Description
array typedArray the data to send to buffer
offset uint the offset in byte where the data will be written
Source: