--- title: WebGLRenderingContext.bindBuffer() slug: Web/API/WebGLRenderingContext/bindBuffer translation_of: Web/API/WebGLRenderingContext/bindBuffer ---
ebGLRenderingContext.bindBuffer()
метод WebGL API связывает {{domxref("WebGLBuffer")}} c точкой связывания(Атрибут регистром).
void gl.bindBuffer(target, buffer);
gl.ARRAY_BUFFER
: Буфер содержащий вершинные атрибуты, такие как координаты, текстурные координаты(UV) или цвет вершины.gl.ELEMENT_ARRAY_BUFFER
: Буфер использующий для индексирования элементов.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.Нет.
Only one target can be bound to a given {{domxref("WebGLBuffer")}}. An attempt to bind the buffer to another target will throw an INVALID_OPERATION
error and the current buffer binding will remain the same.
var canvas = document.getElementById('canvas'); var gl = canvas.getContext('webgl'); var buffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
To check the current buffer bindings, query the ARRAY_BUFFER_BINDING
and ELEMENT_ARRAY_BUFFER_BINDING
constants.
gl.getParameter(gl.ARRAY_BUFFER_BINDING); gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING);
Specification | Status | Comment |
---|---|---|
{{SpecName('WebGL', "#5.14.5", "bindBuffer")}} | {{Spec2('WebGL')}} | Initial definition for WebGL. |
{{SpecName('OpenGL ES 2.0', "glBindBuffer.xml", "glBindBuffer")}} | {{Spec2('OpenGL ES 2.0')}} | Man page of the (similar) OpenGL ES 2 API. |
{{SpecName('WebGL2', "#3.7.1", "bindBuffer")}} | {{Spec2('WebGL2')}} |
Updated definition for WebGL 2. Adds new |
{{SpecName('OpenGL ES 3.0', "glBindBuffer.xhtml", "glBindBuffer")}} | {{Spec2('OpenGL ES 3.0')}} | Man page of the (similar) OpenGL ES 3 API. |
{{Compat("api.WebGLRenderingContext.bindBuffer")}}