This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.
* Some parts of this feature may have varying levels of support.
Note: This feature is available in Web Workers.
The WebGL2RenderingContext.bufferSubData() method of the WebGL API updates a subset of a buffer object's data store.
bufferSubData(target, dstByteOffset, srcData) bufferSubData(target, dstByteOffset, srcData, srcOffset) bufferSubData(target, dstByteOffset, srcData, srcOffset, length)
targetA GLenum specifying the binding point (target). Possible values:
gl.ARRAY_BUFFERBuffer containing vertex attributes, such as vertex coordinates, texture coordinate data, or vertex color data.
gl.ELEMENT_ARRAY_BUFFERBuffer used for element indices.
gl.COPY_READ_BUFFERBuffer for copying from one buffer object to another.
gl.COPY_WRITE_BUFFERBuffer for copying from one buffer object to another.
gl.TRANSFORM_FEEDBACK_BUFFERBuffer for transform feedback operations.
gl.UNIFORM_BUFFERBuffer used for storing uniform blocks.
gl.PIXEL_PACK_BUFFERBuffer used for pixel transfer operations.
gl.PIXEL_UNPACK_BUFFERBuffer used for pixel transfer operations.
dstByteOffsetA GLintptr specifying an offset in bytes where the data replacement will start.
srcData OptionalA TypedArray or a DataView that views an ArrayBuffer or SharedArrayBuffer that will be copied into the data store.
srcOffset OptionalA GLuint specifying the element index offset where to start reading the buffer.
length OptionalA GLuint defaulting to 0, where 0 means bufferSubData should calculate the length.
None (undefined).
gl.INVALID_VALUE error is thrown if the data would be written past the end of the buffer or if data is null.gl.INVALID_ENUM error is thrown if target is not one of the allowed enums.| Specification |
|---|
| WebGL Specification> # 5.14.5> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
bufferSubData |
56 | 79 | 51 | 43 | 15 | 58 | 51 | 43 | 15 | 7.0 | 58 | 15 |
srcData_param_accepts_SharedArrayBuffer |
60 | 79 | 79 | 47 | No | 60 | 79 | 44 | No | 8.0 | 60 | No |
WebGLRenderingContext.bufferSubData()WebGLRenderingContext.createBuffer()WebGLRenderingContext.bufferData()WebGLFramebuffer, WebGLRenderbuffer
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/bufferSubData