-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor docs to separate WebGL v1 and v2 content. #32613
Changes from 6 commits
9f89252
9244877
12db939
4cb7842
d25e127
709ff4e
794636e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
--- | ||
title: "WebGL2RenderingContext: bufferData() method" | ||
short-title: bufferData() | ||
slug: Web/API/WebGL2RenderingContext/bufferData | ||
page-type: web-api-instance-method | ||
browser-compat: api.WebGL2RenderingContext.bufferData | ||
--- | ||
|
||
{{APIRef("WebGL")}} | ||
|
||
The **`WebGL2RenderingContext.bufferData()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) creates and initializes the buffer object's data store. | ||
|
||
## Syntax | ||
|
||
```js-nolint | ||
bufferData(target, size, usage) | ||
bufferData(target, srcData, usage) | ||
bufferData(target, srcData, usage, srcOffset) | ||
bufferData(target, srcData, usage, srcOffset, length) | ||
``` | ||
|
||
### Parameters | ||
|
||
- `target` | ||
|
||
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values: | ||
|
||
- `gl.ARRAY_BUFFER` | ||
- : Buffer containing vertex attributes, such as | ||
vertex 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. | ||
|
||
- `size` {{optional_inline}} | ||
- : A {{domxref("WebGL_API/Types", "GLsizeiptr")}} setting the size in bytes of the buffer object's data | ||
store. | ||
One of `size` and `srcData` must be provided. | ||
- `srcData` {{optional_inline}} | ||
- : An {{jsxref("ArrayBuffer")}}, {{jsxref("SharedArrayBuffer")}}, a {{jsxref("TypedArray")}} or a {{jsxref("DataView")}} | ||
that will be copied into the data store. | ||
If `null`, a data store is still created, but the content is uninitialized and undefined. | ||
One of `size` and `srcData` must be provided. | ||
- `usage` | ||
|
||
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the intended usage pattern of the data store | ||
tsnee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for optimization purposes. Possible values: | ||
|
||
- `gl.STATIC_DRAW` | ||
- : The contents are intended to be specified | ||
once by the application, and used many times as the source for WebGL | ||
drawing and image specification commands. | ||
- `gl.DYNAMIC_DRAW` | ||
- : The contents are intended to be respecified | ||
repeatedly by the application, and used many times as the source for WebGL | ||
drawing and image specification commands. | ||
- `gl.STREAM_DRAW` | ||
- : The contents are intended to be specified | ||
once by the application, and used at most a few times as the source for | ||
WebGL drawing and image specification commands. | ||
- `gl.STATIC_READ` | ||
- : The contents are intended to be | ||
specified once by reading data from WebGL, and queried many times | ||
by the application. | ||
- `gl.DYNAMIC_READ` | ||
- : The contents are intended to be | ||
respecified repeatedly by reading data from WebGL, and queried | ||
many times by the application. | ||
- `gl.STREAM_READ` | ||
- : The contents are intended to be | ||
specified once by reading data from WebGL, and queried at most a | ||
few times by the application | ||
- `gl.STATIC_COPY` | ||
- : The contents are intended to be | ||
specified once by reading data from WebGL, and used many times as | ||
the source for WebGL drawing and image specification commands. | ||
- `gl.DYNAMIC_COPY` | ||
- : The contents are intended to be | ||
respecified repeatedly by reading data from WebGL, and used many | ||
times as the source for WebGL drawing and image specification | ||
commands. | ||
- `gl.STREAM_COPY` | ||
- : The contents are intended to be | ||
specified once by reading data from WebGL, and used at most a few | ||
times as the source for WebGL drawing and image specification | ||
commands. | ||
|
||
- `srcOffset` {{optional_inline}} | ||
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the element index offset where to start reading | ||
the buffer. | ||
Only allowed if `srcData` is provided. | ||
- `length` {{optional_inline}} | ||
- : A {{domxref("WebGL_API/Types", "GLuint")}} defaulting to 0. | ||
tsnee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Only allowed if `srcOffset` is given. | ||
|
||
### Return value | ||
|
||
None ({{jsxref("undefined")}}). | ||
|
||
### Exceptions | ||
|
||
- A `gl.OUT_OF_MEMORY` error is thrown if the context is unable to create | ||
a data store with the given `size`. | ||
- A `gl.INVALID_VALUE` error is thrown if `size` is negative. | ||
- A `gl.INVALID_ENUM` error is thrown if `target` or | ||
`usage` are not one of the allowed enums. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("WebGLRenderingContext.bufferData()")}} | ||
- {{domxref("WebGLRenderingContext.createBuffer()")}} | ||
- {{domxref("WebGLRenderingContext.bufferSubData()")}} | ||
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
title: "WebGL2RenderingContext: bufferSubData() method" | ||
short-title: bufferSubData() | ||
slug: Web/API/WebGL2RenderingContext/bufferSubData | ||
page-type: web-api-instance-method | ||
browser-compat: api.WebGL2RenderingContext.bufferSubData | ||
--- | ||
|
||
{{APIRef("WebGL")}} | ||
|
||
The **`WebGL2RenderingContext.bufferSubData()`** method of the | ||
[WebGL API](/en-US/docs/Web/API/WebGL_API) updates a subset of a buffer | ||
object's data store. | ||
|
||
## Syntax | ||
|
||
```js-nolint | ||
bufferSubData(target, dstByteOffset, srcData) | ||
bufferSubData(target, dstByteOffset, srcData, srcOffset) | ||
bufferSubData(target, dstByteOffset, srcData, srcOffset, length) | ||
``` | ||
|
||
### Parameters | ||
|
||
- `target` | ||
|
||
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values: | ||
|
||
- `gl.ARRAY_BUFFER` | ||
- : Buffer containing vertex attributes, such as | ||
vertex coordinates, texture coordinate data, or vertex color data. | ||
- `gl.ELEMENT_ARRAY_BUFFER` | ||
- : Buffer used for element indices. | ||
- `gl.COPY_READ_BUFFER` | ||
tsnee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- : 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. | ||
|
||
- `dstByteOffset` | ||
- : A {{domxref("WebGL_API/Types", "GLintptr")}} specifying an offset in bytes where the data replacement | ||
will start. | ||
- `srcData` {{optional_inline}} | ||
- : An {{jsxref("ArrayBuffer")}}, {{jsxref("SharedArrayBuffer")}}, a {{jsxref("DataView")}}, or a {{jsxref("TypedArray")}} | ||
that will be copied into the data store. | ||
- `srcOffset` {{optional_inline}} | ||
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the element index offset where to start reading | ||
the buffer. | ||
- `length` {{optional_inline}} | ||
- : A {{domxref("WebGL_API/Types", "GLuint")}} defaulting to 0, where 0 means `bufferSubData` should calculate the length. | ||
|
||
### Return value | ||
|
||
None ({{jsxref("undefined")}}). | ||
|
||
### Exceptions | ||
|
||
- A `gl.INVALID_VALUE` error is thrown if the data would be written past | ||
the end of the buffer or if `data` is `null`. | ||
- A `gl.INVALID_ENUM` error is thrown if `target` is not one of | ||
the allowed enums. | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("WebGLRenderingContext.bufferSubData()")}} | ||
- {{domxref("WebGLRenderingContext.createBuffer()")}} | ||
- {{domxref("WebGLRenderingContext.bufferData()")}} | ||
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,6 @@ buffer object's data store. | |
bufferData(target, usage) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks to me like either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
bufferData(target, size, usage) | ||
bufferData(target, srcData, usage) | ||
|
||
// WebGL2 | ||
bufferData(target, usage, srcOffset) | ||
bufferData(target, srcData, usage, srcOffset) | ||
bufferData(target, srcData, usage, srcOffset, length) | ||
Comment on lines
-21
to
-25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't leave a suggestion but "// WebGL1" above should be removed as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
``` | ||
|
||
### Parameters | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't comment below but maybe mark There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I accepted your suggestion. |
||
|
@@ -106,12 +101,6 @@ bufferData(target, srcData, usage, srcOffset, length) | |
times as the source for WebGL drawing and image specification | ||
commands. | ||
|
||
- `srcOffset` | ||
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the element index offset where to start reading | ||
the buffer. | ||
- `length` {{optional_inline}} | ||
- : A {{domxref("WebGL_API/Types", "GLuint")}} defaulting to 0. | ||
|
||
### Return value | ||
|
||
None ({{jsxref("undefined")}}). | ||
|
@@ -165,6 +154,7 @@ const sizeInBytes = dataArray.length * dataArray.BYTES_PER_ELEMENT; | |
|
||
## See also | ||
|
||
- {{domxref("WebGL2RenderingContext.bufferData()")}} | ||
- {{domxref("WebGLRenderingContext.createBuffer()")}} | ||
- {{domxref("WebGLRenderingContext.bufferSubData()")}} | ||
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,8 @@ object's data store. | |
## Syntax | ||
|
||
```js-nolint | ||
// WebGL1 | ||
bufferSubData(target, offset) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like this option is not valid, from the spec?
(also it's called |
||
bufferSubData(target, offset, srcData) | ||
|
||
// WebGL2 | ||
bufferSubData(target, dstByteOffset, srcOffset) | ||
bufferSubData(target, dstByteOffset, srcData, srcOffset) | ||
bufferSubData(target, dstByteOffset, srcData, srcOffset, length) | ||
``` | ||
|
||
### Parameters | ||
|
@@ -100,6 +94,7 @@ gl.bufferSubData(gl.ARRAY_BUFFER, 512, data); | |
|
||
## See also | ||
|
||
- {{domxref("WebGL2RenderingContext.bufferSubData()")}} | ||
- {{domxref("WebGLRenderingContext.createBuffer()")}} | ||
- {{domxref("WebGLRenderingContext.bufferData()")}} | ||
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks as if, in the BCD structure that this line references, the
spec_url
value wrongly links to v1 of the sec: https://github.com/mdn/browser-compat-data/blob/c903034cce9708f86c0a4f03aa2a4cf37df90e8f/api/WebGL2RenderingContext.json#L770, which is why the link in the "Specifications" section in this page is wrong. We can't fix that in this PR but should fix it in https://github.com/mdn/browser-compat-data/. I can take care of that unless you want to.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!