glClearBufferData.3G - Man Page

fill a buffer object's data store with a fixed value

C Specification

void glClearBufferData(GLenum target, GLenum internalformat, GLenum format, GLenum type, const void * data);

void glClearNamedBufferData(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);

Parameters

target

Specifies the target to which the buffer object is bound for glClearBufferData, which must be one of the buffer binding targets in the following table:

Buffer Binding TargetPurpose
GL_ARRAY_BUFFERVertex attributes
GL_ATOMIC_COUNTER_BUFFERAtomic counter storage
GL_COPY_READ_BUFFERBuffer copy source
GL_COPY_WRITE_BUFFERBuffer copy destination
GL_DISPATCH_INDIRECT_BUFFERIndirect compute dispatch commands
GL_DRAW_INDIRECT_BUFFERIndirect command arguments
GL_ELEMENT_ARRAY_BUFFERVertex array indices
GL_PIXEL_PACK_BUFFERPixel read target
GL_PIXEL_UNPACK_BUFFERTexture data source
GL_QUERY_BUFFERQuery result buffer
GL_SHADER_STORAGE_BUFFERRead-write storage for shaders
GL_TEXTURE_BUFFERTexture data buffer
GL_TRANSFORM_FEEDBACK_BUFFERTransform feedback buffer
GL_UNIFORM_BUFFERUniform block storage
buffer

Specifies the name of the buffer object for glClearNamedBufferData.

internalformat

The internal format with which the data will be stored in the buffer object.

format

The format of the data in memory addressed by data.

type

The type of the data in memory addressed by data.

data

The address of a memory location storing the data to be replicated into the buffer's data store.

Description

glClearBufferData and glClearNamedBufferData fill the entirety of a buffer object's data store with data from client memory.

Data, initially supplied in a format specified by format in data type type is read from the memory address given by data and converted into the internal representation given by internalformat, which must be one of the following sized internal formats:

    Component
Sized Internal FormatBase TypeComponentsNorm0123
GL_R8ubyte1YESR001
GL_R16ushort1YESR001
GL_R16Fhalf1NOR001
GL_R32Ffloat1NOR001
GL_R8Ibyte1NOR001
GL_R16Ishort1NOR001
GL_R32Iint1NOR001
GL_R8UIubyte1NOR001
GL_R16UIushort1NOR001
GL_R32UIuint1NOR001
GL_RG8ubyte2YESRG01
GL_RG16ushort2YESRG01
GL_RG16Fhalf2NORG01
GL_RG32Ffloat2NORG01
GL_RG8Ibyte2NORG01
GL_RG16Ishort2NORG01
GL_RG32Iint2NORG01
GL_RG8UIubyte2NORG01
GL_RG16UIushort2NORG01
GL_RG32UIuint2NORG01
GL_RGB32Ffloat3NORGB1
GL_RGB32Iint3NORGB1
GL_RGB32UIuint3NORGB1
GL_RGBA8uint4YESRGBA
GL_RGBA16short4YESRGBA
GL_RGBA16Fhalf4NORGBA
GL_RGBA32Ffloat4NORGBA
GL_RGBA8Ibyte4NORGBA
GL_RGBA16Ishort4NORGBA
GL_RGBA32Iint4NORGBA
GL_RGBA8UIubyte4NORGBA
GL_RGBA16UIushort4NORGBA
GL_RGBA32UIuint4NORGBA

This converted data is then replicated throughout the buffer object's data store. If data is NULL, then the buffer's data store is filled with zeros.

Errors

GL_INVALID_ENUM is generated by glClearBufferData if target is not one of the generic buffer binding targets.

GL_INVALID_VALUE is generated by glClearBufferData if no buffer is bound target.

GL_INVALID_OPERATION is generated by glClearNamedBufferData if buffer is not the name of an existing buffer object.

GL_INVALID_ENUM is generated if internalformat is not one of the valid sized internal formats listed in the table above.

GL_INVALID_OPERATION is generated if any part of the specified range of the buffer object is mapped with glMapBufferRange() or glMapBuffer(), unless it was mapped with the GL_MAP_PERSISTENT_BIT bit set in the glMapBufferRange access flags.

GL_INVALID_VALUE is generated if format is not a valid format, or type is not a valid type.

Version Support

OpenGL Version
Function / Feature Name2.02.13.03.13.23.34.04.14.24.34.44.5
glClearBufferData---------
glClearNamedBufferData-----------

See Also

glClearBufferSubData().

Referenced By

glClearBufferSubData.3G(3).

The man page glClearNamedBufferData.3G(3) is an alias of glClearBufferData.3G(3).

01/24/2024