glBufferData

creates and initializes a buffer object's data store

Signature

glBufferData( GLenum ( target ) , GLsizeiptr ( size ) , const void * ( data ) , GLenum ( usage ) )-> void
glBufferData( target , size , data , usage )
Copy given data into the currently bound vertex-buffer-data object

    target -- the symbolic constant indicating which buffer type is intended
    size -- if provided, the count-in-bytes of the array
    data -- data-pointer to be used, may be None to initialize without
        copying over a data-set
    usage -- hint to the driver as to how to set up access to the buffer

    Note: parameter "size" can be omitted, which makes the signature
        glBufferData( target, data, usage )
    instead of:
        glBufferData( target, size, data, usage )
    
glNamedBufferData( GLuint ( buffer ) , GLsizeiptr ( size ) , const void *( data ) , GLenum ( usage ) )-> void
glNamedBufferData( buffer , size , data , usage )

Parameters

VariablesDescription
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:
buffer
Specifies the name of the buffer object for glNamedBufferData function.
size
Specifies the size in bytes of the buffer object's new data store.
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.
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 .

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. The frequency of access may be one of these:
STREAM
The data store contents will be modified once and used at most a few times.
STATIC
The data store contents will be modified once and used many times.
DYNAMIC
The data store contents will be modified repeatedly and used many times.
The nature of access may be one of these:
DRAW
The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
READ
The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
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.

Notes

If data is NULL , a data store of the specified size is still created, but its contents remain uninitialized and thus undefined.
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 .
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 glBufferData if target is not one of the accepted buffer targets.
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 .
GL_INVALID_VALUE is generated if size is negative.
GL_INVALID_OPERATION is generated by glBufferData if the reserved buffer object name 0 is bound to target .
GL_INVALID_OPERATION is generated by glNamedBufferData if buffer is not the name of an existing buffer object.
GL_INVALID_OPERATION is generated if the GL_BUFFER_IMMUTABLE_STORAGE flag of the buffer object is GL_TRUE .
GL_OUT_OF_MEMORY is generated if the GL is unable to create a data store with the specified size .

Associated Gets

glGetBufferParameter with argument GL_BUFFER_SIZE or GL_BUFFER_USAGE

Version Support

glBufferData
glNamedBufferData

See Also

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

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glBufferData
{LGPL} Pyggel pyggel/data.py Lines: 347, 353, 359, 365
OpenGL Tutorial (Python Translation) t02.playing-with-colors/FragPosition.py Lines: 64
OpenGL Tutorial (Python Translation) t02.playing-with-colors/VertexColors.py Lines: 67
OpenGL Tutorial (Python Translation) t01.hello-triangle/HelloTriangle.py Lines: 78
{GPL3} OpenGL-Programmable 05-shader.py Lines: 161, 164
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 176, 179
{GPL3} OpenGL-Programmable 09-gles2.py Lines: 152, 206, 209, 260
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 169, 172
{GPL3} OpenGL-Programmable 10-gl3.2core.py Lines: 160, 216, 219, 270
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 95, 98
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 134, 187, 190, 238

MathML Rendering

Powered by MathJax