GL.Buffer Class
A data buffer to be stored in the GPU
Constructor
GL.Buffer
-
target
-
data
-
spacing
-
stream_type
Parameters:
-
target
Numbergl.ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER
-
data
ArrayBufferViewthe data in typed-array format
-
spacing
Numbernumber of numbers per component (3 per vertex, 2 per uvs...), default 3
-
stream_type
Enumdefault gl.STATIC_DRAW (other: gl.DYNAMIC_DRAW, gl.STREAM_DRAW
Item Index
Methods
Methods
applyTransform
-
mat
Applies a mat4 transform to every triplets in the buffer (assuming they are points) No upload is performed (to ensure efficiency in case there are several operations performed)
Parameters:
-
mat
Mat4
clone
-
share
Clones one buffer (it allows to share the same data between both buffers)
Parameters:
-
share
Booleanif you want that both buffers share the same data (default false) return {GL.Buffer} buffer cloned
delete
()
Deletes the content from the GPU and destroys the handler
forEach
-
callback
Applies an action to every vertex in this buffer
Parameters:
-
callback
Functionto be called for every vertex (or whatever is contained in the buffer)
setData
-
data
-
offset
Assign data to buffer and uploads it (it allows range)
Parameters:
-
data
ArrayBufferViewin Float32Array format usually
-
offset
Numberoffset in bytes
upload
-
stream_type
Uploads the buffer data (stored in this.data) to the GPU
Parameters:
-
stream_type
Numberdefault gl.STATIC_DRAW (other: gl.DYNAMIC_DRAW, gl.STREAM_DRAW
uploadRange
-
start
-
size
Uploads part of the buffer data (stored in this.data) to the GPU
Parameters:
-
start
Numberoffset in bytes
-
size
Numbersizes in bytes