CreateDDSTextureFromMemory

Creates a texture resource and a shader resource view, given the image of a file in a memory buffer.

Syntax

HRESULT CreateDDSTextureFromMemory(
         ID3D11Device *d3dDevice,
         const _In_reads_bytes_(ddsDataSize) uint8_t *ddsData,
         size_t ddsDataSize,
         ID3D11Resource **texture,
         ID3D11ShaderResourceView **textureView,
         size_t maxsize
)  

Parameters

d3dDevice
Type: ID3D11Device *

[in] The DirectX 11 device created on initialization.

ddsData
Type: In_reads_bytes(ddsDataSize) uint8_t *

Pointer to the memory buffer.

ddsDataSize
Type: size_t 

[in] The size of the DDS image, in bytes.

texture
Type: ID3D11Resource **

Pointer to a texture resource to be created.

textureView
Type: ID3D11ShaderResourceView **

Pointer to a shader resourse view to be created.

maxsize
Type: size_t 

[in] If non-zero, this is the maximum size of mipmap level to load and create. If this is set to zero then no mipmap levels are created if the method succeeds, but if the method fails and there are mipmaps present, then a second attempt will be made with the maxmimum mipmap level determined by the DirectX feature level setting. The purpose of this parameter is to enable some load balancing.

Return value

Type: HRESULT 

A success or error code.

Remarks

This method does not perform any format conversion. It does support 1D, 2D, mipmap levels, volume maps, cube maps, compression formats, and texture arrays.

This method can be found in the DDSTextureLoader.cpp file, included along with the DirectXTex files in the Xbox One samples.

Requirements

Header: Declared in DDSTextureLoader.h.