Name

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

C Specification

void glBufferData(GLenum target,
 GLsizeiptr size,
 const GLvoid * data,
 GLenum usage);
 

Parameters

target

Specifies the target buffer object. The symbolic constant must be GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.

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_STATIC_DRAW or GL_DYNAMIC_DRAW.

Description

glBufferData creates a new data store for the buffer object currently bound to target. 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.

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 may be one of these:

GL_STATIC_DRAW

The data store contents will be modified once and used many times as the source for GL drawing commands.

GL_DYNAMIC_DRAW

The data store contents will be modified repeatedly and used many times as the source for GL drawing 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 consistent 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.

Errors

GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.

GL_INVALID_ENUM is generated if usage is not GL_STATIC_DRAW or GL_DYNAMIC_DRAW.

GL_INVALID_VALUE is generated if size is negative.

GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.

GL_OUT_OF_MEMORY is generated if the GL is unable to create a data store with the specified size.

Associated Gets

glGetBufferParameteriv with argument GL_BUFFER_SIZE or GL_BUFFER_USAGE

See Also

glBufferSubData, glBindBuffer

Copyright

Copyright © 2003-2004 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.