new ArrayBuffer(gl, dataopt, usageopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
gl |
WebGLRenderingContext | then webgl context this ArrayBuffer belongs to | ||
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
attrib(name, size, type, normalizeopt)
Add attribute declaration for this buffer. Once attributes declared, the buffer can be linked to
programs attributes using ArrayBuffer#attribPointer
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | the name of the program's attribute | ||
size |
uint | the size of the attribute (3 for a vec3) | ||
type |
GLenum | the type of data (GL_FLOAT, GL_SHORT etc) | ||
normalize |
boolean |
<optional> |
false | indicate if the data must be normalized |
- Source:
attribPointer(program)
Link given program attributes to this buffer. You should first declare attributes using ArrayBuffer#attrib
before calling this method.
Parameters:
Name | Type | Description |
---|---|---|
program |
Program | the nanogl Program |
- Source:
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 vertices to draw (full buffer is used if omited) | |
offset |
uint |
<optional> |
0 | the position of the first vertex 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: