Creates a buffer in memory and initializes it with array data. If no array is provided, the contents of the buffer is initialized to 0.
SyntaxWebGLRenderingContext.bufferData(target, size or data, usage);
- target [in]
Set to gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER.
- size or data [in]
Type: number or ArrayBuffer
An array of data points, or the size of the buffer to initialize.
- usage [in]
One of the following values:
- gl.STATIC_DRAW The data store contents are modified once, and used many times as the source for WebGL drawing commands.
- gl.DYNAMIC_DRAW The data store contents are repeatedly respecified, and used many times as the source for WebGL drawing commands.
- gl.STREAM_DRAW The data store contents are specified once, and used occasionally as the source of a WebGL drawing command.
Usage is provided only as a performance hint. The usage value doesn't restrict the way the data store is used.
This method does not return a value.
|gl.OUT_OF_MEMORY||If WebGL can't create the buffer to the requested size.|
BufferData deletes any existing data store and sets the state variables gl.BUFFER_SIZE and gl.BUFFER_USAGE to the new values.