glBindVertexBuffer - OpenGL 4 Reference Pages

## Name

glBindVertexBuffer, glVertexArrayVertexBuffer — bind a buffer to a vertex buffer bind point

## C Specification

`void glBindVertexBuffer(` | GLuint bindingindex,
| GLuint buffer,
| GLintptr offset,
| GLintptr stride`)`;

`void glVertexArrayVertexBuffer(` | GLuint vaobj,
| GLuint bindingindex,
| GLuint buffer,
| GLintptr offset,
| GLsizei stride`)`;

## Parameters

`vaobj`

  Specifies the name of the vertex array object to be used by `glVertexArrayVertexBuffer` function.

`bindingindex`

  The index of the vertex buffer binding point to which to bind the buffer.

`buffer`

  The name of a buffer to bind to the vertex buffer binding point.

`offset`

  The offset of the first element of the buffer.

`stride`

  The distance between elements within the buffer.

## Description

`glBindVertexBuffer` and `glVertexArrayVertexBuffer` bind the buffer named `buffer` to the vertex buffer binding point whose index is given by `bindingindex`. `glBindVertexBuffer` modifies the binding of the currently bound vertex array object, whereas `glVertexArrayVertexBuffer` allows the caller to specify ID of the vertex array object with an argument named `vaobj`, for which the binding should be modified. `offset` and `stride` specify the offset of the first element within the buffer and the distance between elements within the buffer, respectively, and are both measured in basic machine units. `bindingindex` must be less than the value of `GL_MAX_VERTEX_ATTRIB_BINDINGS`. `offset` and `stride` must be greater than or equal to zero. If `buffer` is zero, then any buffer currently bound to the specified binding point is unbound.

If `buffer` is not the name of an existing buffer object, the GL first creates a new state vector, initialized with a zero-sized memory buffer and comprising all the state and with the same initial values as in case of `glBindBuffer`. `buffer` is then attached to the specified `bindingindex` of the vertex array object.

## Errors

`GL_INVALID_OPERATION` is generated by `glBindVertexBuffer` if no vertex array object is bound.

`GL_INVALID_OPERATION` is generated by `glVertexArrayVertexBuffer` if `vaobj` is not the name of an existing vertex array object.

`GL_INVALID_VALUE` is generated if `bindingindex` is greater than or equal to the value of `GL_MAX_VERTEX_ATTRIB_BINDINGS`.

`GL_INVALID_VALUE` is generated if `offset` or `stride` is less than zero, or if stride is greater than the value of `GL_MAX_VERTEX_ATTRIB_STRIDE`.

`GL_INVALID_VALUE` is generated if `buffer` is not zero or the name of an existing buffer object (as returned by `glGenBuffers` or `glCreateBuffers`).

## Associated Gets

glGet with argument `GL_MAX_VERTEX_ATTRIB_BINDINGS`.

## Version Support

| OpenGL Version
--- | ---
Function / Feature Name | 2.0 | 2.1 | 3.0 | 3.1 | 3.2 | 3.3 | 4.0 | 4.1 | 4.2 | 4.3 | 4.4 | 4.5
`glBindVertexBuffer` | - | - | - | - | - | - | - | - | - | ✔ | ✔ | ✔
`glVertexArrayVertexBuffer` | - | - | - | - | - | - | - | - | - | - | - | ✔

## See Also

glVertexAttribBinding, glVertexAttribFormat, glVertexAttribPointer, glVertexBindingDivisor.

## Copyright

Copyright © 2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.