Light | Dark

# docs.GL

OpenGL 4
OpenGL 3
OpenGL ES 3

# glGetBufferParameter

## Name

glGetBufferParameter — return parameters of a buffer object

## C Specification

`void glGetBufferParameteriv(` | GLenum target,
| GLenum value,
| GLint * data`)`;

`void glGetBufferParameteri64v(` | GLenum target,
| GLenum value,
| GLint64 * data`)`;

`void glGetNamedBufferParameteriv(` | GLuint buffer,
| GLenum pname,
| GLint *params`)`;

`void glGetNamedBufferParameteri64v(` | GLuint buffer,
| GLenum pname,
| GLint64 *params`)`;

## Parameters

`target`

  Specifies the target to which the buffer object is bound for `glGetBufferParameteriv` and `glGetBufferParameteri64v`. Must be one of the buffer binding targets in the following table:

  Buffer Binding Target | Purpose
  --- | ---
  `GL_ARRAY_BUFFER` | Vertex attributes
  `GL_ATOMIC_COUNTER_BUFFER` | Atomic counter storage
  `GL_COPY_READ_BUFFER` | Buffer copy source
  `GL_COPY_WRITE_BUFFER` | Buffer copy destination
  `GL_DISPATCH_INDIRECT_BUFFER` | Indirect compute dispatch commands
  `GL_DRAW_INDIRECT_BUFFER` | Indirect command arguments
  `GL_ELEMENT_ARRAY_BUFFER` | Vertex array indices
  `GL_PIXEL_PACK_BUFFER` | Pixel read target
  `GL_PIXEL_UNPACK_BUFFER` | Texture data source
  `GL_QUERY_BUFFER` | Query result buffer
  `GL_SHADER_STORAGE_BUFFER` | Read-write storage for shaders
  `GL_TEXTURE_BUFFER` | Texture data buffer
  `GL_TRANSFORM_FEEDBACK_BUFFER` | Transform feedback buffer
  `GL_UNIFORM_BUFFER` | Uniform block storage

`buffer`

  Specifies the name of the buffer object for `glGetNamedBufferParameteriv` and `glGetNamedBufferParameteri64v`.

`value`

  Specifies the name of the buffer object parameter to query.

`data`

  Returns the requested parameter.

## Description

These functions return in `data` a selected parameter of the specified buffer object.

`pname` names a specific buffer object parameter, as follows:

`GL_BUFFER_ACCESS`

  `params` returns the access policy set while mapping the buffer object (the value of the `access` parameter enum passed to `glMapBuffer`). If the buffer was mapped with `glMapBufferRange`, the access policy is determined by translating the bits in that `access` parameter to one of the supported enums for `glMapBuffer` as described in the OpenGL Specification.

`GL_BUFFER_ACCESS_FLAGS`

  `params` returns the access policy set while mapping the buffer object (the value of the `access` parameter bitfield passed to `glMapBufferRange`). If the buffer was mapped with `glMapBuffer`, the access policy is determined by translating the enums in that `access` parameter to the corresponding bits for `glMapBufferRange` as described in the OpenGL Specification. The initial value is zero.

`GL_BUFFER_IMMUTABLE_STORAGE`

  `params` returns a boolean flag indicating whether the buffer object is immutable. The initial value is `GL_FALSE`.

`GL_BUFFER_MAPPED`

  `params` returns a flag indicating whether the buffer object is currently mapped. The initial value is `GL_FALSE`.

`GL_BUFFER_MAP_LENGTH`

  `params` returns the length of the mapping into the buffer object established with `glMapBuffer*`. The `i64v` versions of these queries should be used for this parameter. The initial value is zero.

`GL_BUFFER_MAP_OFFSET`

  `params` returns the offset of the mapping into the buffer object established with `glMapBuffer*`. The `i64v` versions of these queries should be used for this parameter. The initial value is zero.

`GL_BUFFER_SIZE`

  `params` returns the size of the buffer object, measured in bytes. The initial value is 0.

`GL_BUFFER_STORAGE_FLAGS`

  `params` returns a bitfield indicating the storage flags for the buffer object. If the buffer object is immutable, the value returned will be that specified when the data store was established with `glBufferStorage`. If the data store was established with `glBufferData`, the value will be `GL_MAP_READ_BIT` | `GL_MAP_WRITE_BIT` | `GL_DYNAMIC_STORAGE_BIT` | `GL_MAP_WRITE_BIT`. The initial value is zero.

`GL_BUFFER_USAGE`

  `params` returns the buffer object's usage pattern. The initial value is `GL_STATIC_DRAW`.

## Notes

If an error is generated, no change is made to the contents of `data`.

The `GL_ATOMIC_COUNTER_BUFFER` target is available only if the GL version is 4.2 or greater.

The `GL_DISPATCH_INDIRECT_BUFFER` and `GL_SHADER_STORAGE_BUFFER` targets are available only if the GL version is 4.3 or greater.

The `GL_QUERY_BUFFER` target is available only if the GL version is 4.4 or greater.

## Errors

`GL_INVALID_ENUM` is generated by `glGetBufferParameter*` if `target` is not one of the accepted buffer targets.

`GL_INVALID_OPERATION` is generated by `glGetBufferParameter*` if zero is bound to `target`.

`GL_INVALID_OPERATION` is generated by `glGetNamedBufferParameter*` if `buffer` is not the name of an existing buffer object.

`GL_INVALID_ENUM` is generated if `pname` is not one of the buffer object parameter names described above.

## 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
`glGetBufferParameteri64v` | - | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
`glGetBufferParameteriv` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
`glGetNamedBufferParameteri64v` | - | - | - | - | - | - | - | - | - | - | - | ✔
`glGetNamedBufferParameteriv` | - | - | - | - | - | - | - | - | - | - | - | ✔

## See Also

glBindBuffer, glBufferData, glGetBufferPointerv, glMapBuffer, glUnmapBuffer

## Copyright

Copyright © 2005 Addison-Wesley. Copyright © 2010-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. https://opencontent.org/openpub/.

Think you can improve this page? Edit this page on GitHub.