Home -> ITextureBuffer -> SetInitialData

Description

The SetInitialData method supplies texture data to upload during allocation. The exact overload used depends on texture dimensionality and whether the texture is a cubemap or array texture, but every overload describes source data for a specific mipmap level, face, array entry, or region as appropriate.

Initial data is useful for static textures or for fully populated mipmap chains known before allocation. The source image and data formats describe CPU memory and may differ from the allocated texture format when conversion is supported.

WarningWarning

Initial data is consumed when memory is allocated. The source memory must remain valid and unmodified until AllocateMemory is called.

Usage

template<class T> SuccessToken SetInitialData(const std::vector<T>& sourceBuffer, int mipmapLevel = 0);
template<class T> SuccessToken SetInitialData(const std::vector<T>& sourceBuffer, CubeMapFace targetFace, int mipmapLevel = 0);
template<class T> SuccessToken SetInitialData(const std::vector<T>& sourceBuffer, size_t arrayIndex = 0, int mipmapLevel = 0);
template<class T> SuccessToken SetInitialData(const std::vector<T>& sourceBuffer, CubeMapFace targetFace, size_t arrayIndex = 0, int mipmapLevel = 0);
SuccessToken SetInitialData(const void* sourceBuffer, size_t sourceBufferSizeInBytes, SourceImageFormat imageFormat, SourceDataFormat dataFormat, int mipmapLevel = 0);
SuccessToken SetInitialData(const void* sourceBuffer, size_t sourceBufferSizeInBytes, SourceImageFormat imageFormat, SourceDataFormat dataFormat, CubeMapFace targetFace, int mipmapLevel = 0);
SuccessToken SetInitialData(const void* sourceBuffer, size_t sourceBufferSizeInBytes, SourceImageFormat imageFormat, SourceDataFormat dataFormat, size_t arrayIndex = 0, int mipmapLevel = 0);
SuccessToken SetInitialData(const void* sourceBuffer, size_t sourceBufferSizeInBytes, SourceImageFormat imageFormat, SourceDataFormat dataFormat, CubeMapFace targetFace, size_t arrayIndex = 0, int mipmapLevel = 0);

Argument list

sourceBuffer [const std::vector<T> or const void*]
The source data to use when the texture is allocated.
sourceBufferSizeInBytes [size_t]
The size, in bytes, of the source data.
imageFormat [SourceImageFormat]
The image channel layout of the source data.
dataFormat [SourceDataFormat]
The data encoding of the source data.
targetFace [CubeMapFace]
The cubemap face to initialize for cubemap texture types.
arrayIndex [size_t]
The array element to initialize for array texture types.
mipmapLevel [int]
The mipmap level to initialize.

Return value

[SuccessToken]
True if the operation succeeded, false otherwise. An assertion will be raised in debug builds if the result is not tested.

See also