glBufferData, glNamedBufferData — バッファーオブジェクトのデータストアを作成して初期化します
void glBufferData(
|
GLenum target, |
| GLsizeiptr size, | |
| const void * data, | |
GLenum usage); |
void glNamedBufferData(
|
GLuint buffer, |
| GLsizeiptr size, | |
| const void *data, | |
GLenum usage); |
target
バッファーオブジェクトが glBufferData にバインドされる対象を指定します。
これは、下記の表のバッファーバインド対象の1つである必要があります。
| 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
glNamedBufferData 関数のバッファーオブジェクトの名前を指定します。
size
バッファーオブジェクトの新しいデータストアのサイズをバイト単位で指定します。
data
初期化のためにデータストアにコピーされるデータへのポインターを指定します。
データがコピーされない場合は NULL を指定します。
usage
データストアの予想される使用パターンを指定します。
シンボリック定数は、
GL_STREAM_DRAW、または
GL_STREAM_READ、
GL_STREAM_COPY、
GL_STATIC_DRAW、
GL_STATIC_READ、
GL_STATIC_COPY、
GL_DYNAMIC_DRAW、
GL_DYNAMIC_READ、
GL_DYNAMIC_COPYである必要があります。
glBufferData と
glNamedBufferData は、バッファーオブジェクトの新しいデータストアを作成します。
glBufferData の場合、現在targetにバインドされているバッファーオブジェクトが使用されます。
glNamedBufferData の場合、代わりに、呼び出し元が buffer で指定したIDに関連付けられたバッファーオブジェクトが使用されます。
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:
The data store contents will be modified once and used at most a few times.
The data store contents will be modified once and used many times.
The data store contents will be modified repeatedly and used many times.
The nature of access may be one of these:
The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
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
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.
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.
glGetBufferParameter
with argument GL_BUFFER_SIZE or GL_BUFFER_USAGE
| 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 |
glBufferData
|
✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
glNamedBufferData
|
- | - | - | - | - | - | - | - | - | - | - | ✔ |
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. http://opencontent.org/openpub/.