D3DXCreateTexture function

Creates an empty texture, adjusting the calling parameters as needed.

Syntax

HRESULT D3DXCreateTexture(
  _In_  LPDIRECT3DDEVICE9  pDevice,
  _In_  UINT               Width,
  _In_  UINT               Height,
  _In_  UINT               MipLevels,
  _In_  DWORD              Usage,
  _In_  D3DFORMAT          Format,
  _In_  D3DPOOL            Pool,
  _Out_ LPDIRECT3DTEXTURE9 *ppTexture
);

Parameters

pDevice [in]

Type: LPDIRECT3DDEVICE9

Pointer to an IDirect3DDevice9 interface, representing the device to be associated with the texture.

Width [in]

Type: UINT

Width in pixels. If this value is 0, a value of 1 is used. See Remarks.

Height [in]

Type: UINT

Height in pixels. If this value is 0, a value of 1 is used. See Remarks.

MipLevels [in]

Type: UINT

Number of mip levels requested. If this value is zero or D3DX_DEFAULT, a complete mipmap chain is created.

Usage [in]

Type: DWORD

0, D3DUSAGE_RENDERTARGET, or D3DUSAGE_DYNAMIC. Setting this flag to D3DUSAGE_RENDERTARGET indicates that the surface is to be used as a render target by calling the SetRenderTarget method. If either D3DUSAGE_RENDERTARGET or D3DUSAGE_DYNAMIC is specified, the application should check that the device supports this operation by calling CheckDeviceFormat. For more information about using dynamic textures, see Using Dynamic Textures.

Format [in]

Type: D3DFORMAT

Member of the D3DFORMAT enumerated type, describing the requested pixel format for the texture. The returned texture may be of a different format from that specified, if the device does not support the requested format. Applications should check the format of the returned texture to see if it matches the format requested.

Pool [in]

Type: D3DPOOL

Member of the D3DPOOL enumerated type, describing the memory class into which the texture should be placed.

ppTexture [out]

Type: LPDIRECT3DTEXTURE9*

Address of a pointer to an IDirect3DTexture9 interface, representing the created texture object.

Return value

Type: HRESULT

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DERR_NOTAVAILABLE, D3DERR_OUTOFVIDEOMEMORY, E_OUTOFMEMORY.

Remarks

Internally, D3DXCreateTexture uses D3DXCheckTextureRequirements to adjust the calling parameters. Therefore, calls to D3DXCreateTexture will often succeed where calls to CreateTexture would fail.

If both Height and Width are set to D3DX_DEFAULT, a value of 256 is used for both parameters. If either Height or Width is set to D3DX_DEFAULT And the other parameter is set to a numeric value, the texture will be square with both the height and width equal to the numeric value.

Requirements

Requirement Value
Header
D3dx9tex.h
Library
D3dx9.lib

See also

Texture Functions in D3DX 9