--- title: WebGLRenderingContext.bindBuffer() slug: Web/API/WebGLRenderingContext/bindBuffer translation_of: Web/API/WebGLRenderingContext/bindBuffer ---
{{APIRef("WebGL")}}

ebGLRenderingContext.bindBuffer() метод WebGL API связывает {{domxref("WebGLBuffer")}} c точкой связывания(Атрибут регистром).

Синтаксис

void gl.bindBuffer(target, buffer);

Параметры

target
{{domxref("GLenum")}} определяет точку связывания (target). Возможные значения:
buffer
{{domxref("WebGLBuffer")}} с которым осуществляется связывание.

Return value

Нет.

Exceptions

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.

Examples

Binding a buffer to a target

var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
var buffer = gl.createBuffer();

gl.bindBuffer(gl.ARRAY_BUFFER, buffer);

Getting current bindings

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);

Specifications

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 target buffers:
gl.COPY_READ_BUFFER,
gl.COPY_WRITE_BUFFER,
gl.TRANSFORM_FEEDBACK_BUFFER,
gl.UNIFORM_BUFFER,
gl.PIXEL_PACK_BUFFER,
gl.PIXEL_UNPACK_BUFFER

{{SpecName('OpenGL ES 3.0', "glBindBuffer.xhtml", "glBindBuffer")}} {{Spec2('OpenGL ES 3.0')}} Man page of the (similar) OpenGL ES 3 API.

Browser compatibility

{{Compat("api.WebGLRenderingContext.bindBuffer")}}

See also