glBufferData Function

Syntax

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

Parameters

Name Description
in target Target
in size Vertex data size.
in data Pointer to the vertex data.
in usage Vertex buffer usage.

Return Values

No values are returned.

Description

Loads vertex data into the current vertex buffer object.

Set target equal to GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.

To specify the region that is accessed by the GPU, set target to a bitwise OR of the aforementioned and the following values.

NN_GX_MEM_FCRAMThe GPU accesses main memory.
NN_GX_MEM_VRAMAThe GPU accesses VRAMA.
NN_GX_MEM_VRAMBThe GPU accesses VRAMB. By also specifying the following bitwise OR, you can specify whether to copy data to main memory.
GL_COPY_FCRAM_DMPCreate data copy in main memory.
GL_NO_COPY_FCRAM_DMPDo not create data copy in main memory.

These combinations cause data to be transferred as follows.

(NN_GX_MEM_FCRAM | GL_NO_COPY_FCRAM_DMP)The GPU directly accesses the region specified by data.
(NN_GX_MEM_VRAMA | GL_NO_COPY_FCRAM_DMP)A region is allocated in VRAMA; data is transferred to VRAMA via DMA; and then the GPU accesses VRAMA.
(NN_GX_MEM_VRAMB | GL_NO_COPY_FCRAM_DMP)A region is allocated in VRAMB; data is transferred to VRAMB via DMA; and then the GPU accesses VRAMB.
(NN_GX_MEM_FCRAM | GL_COPY_FCRAM_DMP)A region is allocated in main memory; data is copied to main memory by the CPU; and then the GPU accesses main memory.
(NN_GX_MEM_VRAMA | GL_COPY_FCRAM_DMP)A region is allocated in main memory and VRAMA; data is copied to main memory by the CPU; data is transferred via DMA from main memory to VRAMA, and then the GPU accesses VRAMA.
(NN_GX_MEM_VRAMB | GL_COPY_FCRAM_DMP)A region is allocated in main memory and VRAMB; data is copied to main memory by the CPU; data is transferred via DMA from main memory to VRAMB, and then the GPU accesses VRAMB.

If not specifying any GPU access region or copying to main memory, then (NN_GX_MEM_FCRAM | GL_COPY_FCRAM_DMP) are applied. Set size equal to the vertex data size. You can only set usage to GL_STATIC_DRAW. When data is set to NULL, this function simply allocates a region as large as the data size.

The following errors occur in this function.

GL_INVALID_OPERATIONThis function was called without any command-list objects bound.
GL_INVALID_ENUMtarget was set to an invalid value.
GL_OUT_OF_MEMORYFailed to allocate the management region or the region for the vertex buffer data.
GL_INVALID_OPERATIONtarget was set to an invalid option for the GPU access region and main memory copying.
GL_INVALID_OPERATIONObject 0 is bound to the current target.
GL_INVALID_OPERATIONEither the values NN_GX_MEM_FCRAM | GL_NO_COPY_FCRAM_DMP or the values NN_GX_MEM_VRAMA (or VRAMB) | GL_COPY_FCRAM_DMP were specified, and data is 0.

Revision History

2010/08/11
Corrected an error.
2010/05/07
Added an error code that occurs when the data argument is 0.
2010/03/11
Revised terminology. Added a description of the default value for the target argument.
2010/01/07
Initial version.

CONFIDENTIAL