Saturday, July 30, 2016

glBufferData

Official



Name

glBufferData
  creates and initializes a buffer object's data store.


C Specification

void
glBufferData(
    GLenum target
    , Glsizeiptr size
    , const GLvoid * data
    , GLenum usage
);
,,,
  target specifies the target to which the bufer object is bound for glBufferdata.

  size specifies the size in bytes of the buffer object's new data store.

  data specifies the pointer to data that will be copied into the data store for initialization or null if no data is to be copied.

  usage specifies the expected usage pattern of the data store.

Description

glBufferData and glNamedBufferData create a new data store for a buffer object. In case of glBufferData, the buffer object currently bound to target is used. For glNamedBufferData, a buffer object associated with ID specified by the caller in buffer will be used instead.
While creating the new storage, any pre-existing data store is deleted. The new data store is created with the specified size in bytes and usage. If data is not NULL, the data store is initialized with data from this pointer. In its initial state, the new data store is not mapped, it has a NULL mapped pointer, and its mapped access is GL_READ_WRITE.
usage is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. usage can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. 


What it is



To update your entire buffer, you should call glBufferData() once again:
glBufferData(GL_ARRAY_BUFFER, vertex_size * sizeof(VertexData), vertices, GL_DYNAMIC_DRAW);
Furthermore, it is possible to update only part of the data using the glBufferSubData() call:
glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
The glBufferSubData() is faster since it will not reallocate the underlying buffer .

...By  Sergey K.













No comments:

Post a Comment