GLBUFFERDATA(3G)

  .SH "NAME" glBufferData, glNamedBufferData - creates and initializes a buffer object's data store
  .SH "C SPECIFICATION"

      .HP u void glBufferData(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
      .HP u void glNamedBufferData(GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);

  .SH "PARAMETERS"

      .PP target

              Specifies the target to which the buffer object is bound for glBufferData, which must be one of the buffer binding targets in the following table:
              .TS allbox tab(:); lB lB. T{ Buffer Binding Target T}:T{ Purpose T} l l l l l l l l l l l l l l l l l l l l l l l l l l l l. T{ GL_ARRAY_BUFFER T}:T{ Vertex attributes T} T{ GL_ATOMIC_COUNTER_BUFFER T}:T{ Atomic counter storage T} T{ GL_COPY_READ_BUFFER T}:T{ Buffer copy source T} T{ GL_COPY_WRITE_BUFFER T}:T{ Buffer copy destination T} T{ GL_DISPATCH_INDIRECT_BUFFER T}:T{ Indirect compute dispatch commands T} T{ GL_DRAW_INDIRECT_BUFFER T}:T{ Indirect command arguments T} T{ GL_ELEMENT_ARRAY_BUFFER T}:T{ Vertex array indices T} T{ GL_PIXEL_PACK_BUFFER T}:T{ Pixel read target T} T{ GL_PIXEL_UNPACK_BUFFER T}:T{ Texture data source T} T{ GL_QUERY_BUFFER T}:T{ Query result buffer T} T{ GL_SHADER_STORAGE_BUFFER T}:T{ Read-write storage for shaders T} T{ GL_TEXTURE_BUFFER T}:T{ Texture data buffer T} T{ GL_TRANSFORM_FEEDBACK_BUFFER T}:T{ Transform feedback buffer T} T{ GL_UNIFORM_BUFFER T}:T{ Uniform block storage T}

          .RE
          .PP buffer

                  Specifies the name of the buffer object for glNamedBufferData function.

              .RE
              .PP size

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

                  .RE
                  .PP data

                          Specifies a pointer to data that will be copied into the data store for initialization, or NULL if no data is to be copied.

                      .RE
                      .PP usage

                              Specifies the expected usage pattern of the data store. The symbolic constant must be GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.

                          .RE

                      .SH "DESCRIPTION"

                        .PP 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.
                        .PP 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.
                        .PP 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. The frequency of access may be one of these:

                          .PP STREAM

                                  The data store contents will be modified once and used at most a few times.

                              .RE
                              .PP STATIC

                                      The data store contents will be modified once and used many times.

                                  .RE
                                  .PP DYNAMIC

                                          The data store contents will be modified repeatedly and used many times.

                                      .RE

                                    .PP The nature of access may be one of these:

                                      .PP DRAW

                                              The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.

                                          .RE
                                          .PP READ

                                                  The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.

                                              .RE
                                              .PP COPY

                                                      The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.

                                                  .RE

                                                .SH "NOTES"
                                                    .PP If data is NULL, a data store of the specified size is still created, but its contents remain uninitialized and thus undefined.
                                                    .PP Clients must align data elements consistently with the requirements of the client platform, with an additional base-level requirement that an offset within a buffer to a datum comprising N bytes be a multiple of N.
                                                    .PP The GL_ATOMIC_COUNTER_BUFFER target is available only if the GL version is 4.2 or greater.
                                                    .PP The GL_DISPATCH_INDIRECT_BUFFER and GL_SHADER_STORAGE_BUFFER targets are available only if the GL version is 4.3 or greater.
                                                    .PP The GL_QUERY_BUFFER target is available only if the GL version is 4.4 or greater.

                                              .SH "ERRORS"

                                                .PP GL_INVALID_ENUM is generated by glBufferData if target is not one of the accepted buffer targets.
                                                .PP GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.
                                                .PP GL_INVALID_VALUE is generated if size is negative.
                                                .PP GL_INVALID_OPERATION is generated by glBufferData if the reserved buffer object name 0 is bound to target.
                                                .PP GL_INVALID_OPERATION is generated by glNamedBufferData if buffer is not the name of an existing buffer object.
                                                .PP GL_INVALID_OPERATION is generated if the GL_BUFFER_IMMUTABLE_STORAGE flag of the buffer object is GL_TRUE.
                                                .PP GL_OUT_OF_MEMORY is generated if the GL is unable to create a data store with the specified size.

                                              .SH "ASSOCIATED GETS"

                                                .PP glGetBufferSubData()
                                                .PP glGetBufferParameter() with argument GL_BUFFER_SIZE or GL_BUFFER_USAGE

                                                .SH "VERSION SUPPORT"
                                                    .TS allbox tab(:); lB cB s s s s s s s s s s s lB cB cB cB cB cB cB cB cB cB cB cB cB. T{ T}:T{ OpenGL Version T} T{ Function / Feature Name T}:T{ 2.0 T}:T{ 2.1 T}:T{ 3.0 T}:T{ 3.1 T}:T{ 3.2 T}:T{ 3.3 T}:T{ 4.0 T}:T{ 4.1 T}:T{ 4.2 T}:T{ 4.3 T}:T{ 4.4 T}:T{ 4.5 T} l c c c c c c c c c c c c l c c c c c c c c c c c c. T{ glBufferData T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T}:T{ ✔ T} T{ glNamedBufferData T}:T{ - T}:T{ - T}:T{ - T}:T{ - T}:T{ - T}:T{ - T}:T{ - T}:T{ - T}:T{ - T}:T{ - T}:T{ - T}:T{ ✔ T}

                                                .SH "SEE ALSO"
                                                    .PP glBindBuffer(), glBufferSubData(), glMapBuffer(), glUnmapBuffer()

                                                .SH "COPYRIGHT"
                                                    .PP 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/.

COPYRIGHT
Copyright © 2005 Sams Publishing
Copyright © 2010-2014 Khronos Group