docs.rodeo

MDN Web Docs mirror

WebGLRenderingContext: bufferSubData() method

{{APIRef("WebGL")}} {{AvailableInWorkers}} 

The WebGLRenderingContext.bufferSubData() method of the WebGL API updates a subset of a buffer object’s data store.

Syntax

bufferSubData(target, offset)
bufferSubData(target, offset, srcData)

Parameters

Return value

None ({{jsxref("undefined")}} ).

Exceptions

Examples

Using bufferSubData

const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const buffer = gl.createBuffer();
const data = new Float32Array([1, 2, 3, 4]);
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, 512, data);

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN