## Name

glBindVertexBuffers, glVertexArrayVertexBuffers — attach multiple buffer objects to a vertex array object

## C Specification

`void glBindVertexBuffers(` | GLuint first,
| GLsizei count,
| const GLuint *buffers,
| const GLuintptr *offsets,
| const GLsizei *strides`)`;

`void glVertexArrayVertexBuffers(` | GLuint vaobj,
| GLuint first,
| GLsizei count,
| const GLuint *buffers,
| const GLintptr *offsets,
| const GLsizei *strides`)`;

## Parameters

`vaobj`

  Specifies the name of the vertex array object for `glVertexArrayVertexBuffers`.

`first`

  Specifies the first vertex buffer binding point to which a buffer object is to be bound.

`count`

  Specifies the number of buffers to bind.

`buffers`

  Specifies the address of an array of names of existing buffer objects.

`offsets`

  Specifies the address of an array of offsets to associate with the binding points.

`buffers`

  Specifies the address of an array of strides to associate with the binding points.

## Description

`glBindVertexBuffers` and `glVertexArrayVertexBuffers` bind storage from an array of existing buffer objects to a specified number of consecutive vertex buffer binding points units in a vertex array object. For `glBindVertexBuffers`, the vertex array object is the currently bound vertex array object. For `glVertexArrayVertexBuffers`, `vaobj` is the name of the vertex array object.

`count` existing buffer objects are bound to vertex buffer binding points numbered $first$ through $first + count - 1$. If `buffers` is not NULL, it specifies an array of `count` values, each of which must be zero or the name of an existing buffer object. `offsets` and `strides` specify arrays of `count` values indicating the offset of the first element and stride between elements in each buffer, respectively. If `buffers` is NULL, each affected vertex buffer binding point from $first$ through $first + count - 1$ will be reset to have no bound buffer object. In this case, the offsets and strides associated with the binding points are set to default values, ignoring `offsets` and `strides`.

`glBindVertexBuffers` is equivalent (assuming no errors are generated) to:

        for (i = 0; i < count; i++) {
            if (buffers == NULL) {
                glBindVertexBuffer(first + i, 0, 0, 16);
            } else {
                glBindVertexBuffer(first + i, buffers[i], offsets[i], strides[i]);
            }
        }

except that buffers will not be created if they do not exist.

`glVertexArrayVertexBuffers` is equivalent to the pseudocode above, but replacing `glBindVertexBuffers`(args) with `glVertexArrayVertexBuffers`(vaobj, args).

The values specified in `buffers`, `offsets`, and `strides` will be checked separately for each vertex buffer binding point. When a value for a specific vertex buffer binding point is invalid, the state for that binding point will be unchanged and an error will be generated. However, state for other vertex buffer binding points will still be changed if their corresponding values are valid.

## Errors

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

`GL_INVALID_OPERATION` is generated by `glVertexArrayVertexBuffers` if `vaobj` is not the name of the vertex array object.

`GL_INVALID_OPERATION` is generated if $first + count$ is greater than the value of `GL_MAX_VERTEX_ATTRIB_BINDINGS`.

`GL_INVALID_OPERATION` is generated if any value in `buffers` is not zero or the name of an existing buffer object.

`GL_INVALID_VALUE` is generated if any value in `offsets` or `strides` is negative, or if a value is `stride` is greater than the value of `GL_MAX_VERTEX_ATTRIB_STRIDE`.

## 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
`glBindVertexBuffers` | - | - | - | - | - | - | - | - | - | - | ✔ | ✔
`glVertexArrayVertexBuffers` | - | - | - | - | - | - | - | - | - | - | - | ✔

## See Also

glGenBuffers, glBindBuffer, glDeleteBuffers glDeleteTextures

## 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/.