luma.gl

Buffer

Buffer Methods

Method Description
constructor creates a Buffer
delete Destroys buffer
initializeData Creates and initializes the buffer object’s data store.
updateData Updates a subset of a buffer object’s data store.
bind Binds a buffer to a given binding point (target).
unbind bind(null)
bindBase WebGL2 Binds a buffer to a given binding point (target) at a given index.
unbindBase WebGL2  
bindRange WebGL2 binds a range of a given WebGLBuffer to a given binding point (target) at a given index.
unbindRange WebGL2  
update Updates data in the buffer

Remarks

Class: Buffer

Wraps a WebGLBuffer. A WebGLBuffer is essentially a mechanism to upload memory buffers (attributes) to the GPU (the cost of which can vary depending on whether the system uses a unified memory architecture or not).

Buffer constructor:

Creates a new WebGLBuffer. Also, for all properties set to a buffer, these properties are remembered so they’re optional for later calls.

Syntax:

  import {Buffer} from 'luma.gl';
	const buffer = new Buffer(gl, options);

Arguments:

  1. name - (string) The name (unique id) of the buffer. If no attribute value is set in options then the buffer name will be used as attribute name.
  2. options - (object) An object with options/data described below:

Options:

Examples:

Set buffer values for the vertices of a triangle. The context of this example can be seen [here]http://uber.github.io/luma.gl/examples/lessons/1/).

program.setBuffer('triangle', {
  attribute: 'aVertexPosition',
  value: new Float32Array([0, 1, 0, -1, -1, 0, 1, -1, 0]),
  size: 3
});