Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WebGL2RenderingContext
  4. bufferData()

WebGL2RenderingContext: bufferData() method

Baseline Widely available *

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 inWeb Workers.

TheWebGL2RenderingContext.bufferData() method of theWebGL API creates and initializes the buffer object's data store.

Syntax

js
bufferData(target, size, usage)bufferData(target, srcData, usage)bufferData(target, srcData, usage, srcOffset)bufferData(target, srcData, usage, srcOffset, length)

Parameters

target

AGLenum specifying the binding point (target). Possible values:

gl.ARRAY_BUFFER

Buffer containing vertex attributes, such asvertex coordinates, texture coordinate data, or vertex color data.

gl.ELEMENT_ARRAY_BUFFER

Buffer used for element indices.

gl.COPY_READ_BUFFER

Buffer for copying from one buffer object to another.

gl.COPY_WRITE_BUFFER

Buffer for copying from one buffer object to another.

gl.TRANSFORM_FEEDBACK_BUFFER

Buffer for transform feedback operations.

gl.UNIFORM_BUFFER

Buffer used for storing uniform blocks.

gl.PIXEL_PACK_BUFFER

Buffer used for pixel transfer operations.

gl.PIXEL_UNPACK_BUFFER

Buffer used for pixel transfer operations.

sizeOptional

AGLsizeiptr setting the size in bytes of the buffer object's datastore.One ofsize andsrcData must be provided.

srcDataOptional

ATypedArray or aDataView that views anArrayBuffer orSharedArrayBufferthat will be copied into the data store.Ifnull, a data store is still created, but the content is uninitialized and undefined.One ofsize andsrcData must be provided.

usage

AGLenum specifying the intended usage pattern of the data storefor optimization purposes. Possible values:

gl.STATIC_DRAW

The contents are intended to be specifiedonce by the application, and used many times as the source for WebGLdrawing and image specification commands.

gl.DYNAMIC_DRAW

The contents are intended to be respecifiedrepeatedly by the application, and used many times as the source for WebGLdrawing and image specification commands.

gl.STREAM_DRAW

The contents are intended to be specifiedonce by the application, and used at most a few times as the source forWebGL drawing and image specification commands.

gl.STATIC_READ

The contents are intended to bespecified once by reading data from WebGL, and queried many timesby the application.

gl.DYNAMIC_READ

The contents are intended to berespecified repeatedly by reading data from WebGL, and queriedmany times by the application.

gl.STREAM_READ

The contents are intended to bespecified once by reading data from WebGL, and queried at most afew times by the application

gl.STATIC_COPY

The contents are intended to bespecified once by reading data from WebGL, and used many times asthe source for WebGL drawing and image specification commands.

gl.DYNAMIC_COPY

The contents are intended to berespecified repeatedly by reading data from WebGL, and used manytimes as the source for WebGL drawing and image specificationcommands.

gl.STREAM_COPY

The contents are intended to bespecified once by reading data from WebGL, and used at most a fewtimes as the source for WebGL drawing and image specificationcommands.

srcOffsetOptional

AGLuint specifying the element index offset where to start readingthe buffer.Only allowed ifsrcData is provided.

lengthOptional

AGLuint defaulting to 0.Only allowed ifsrcOffset is given.

Return value

None (undefined).

Exceptions

  • Agl.OUT_OF_MEMORY error is thrown if the context is unable to createa data store with the givensize.
  • Agl.INVALID_VALUE error is thrown ifsize is negative.
  • Agl.INVALID_ENUM error is thrown iftarget orusage are not one of the allowed enums.

Specifications

Specification
WebGL Specification
# 5.14.5

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp