?/TD>
Microsoft DirectX 9.0

D3DXCreateTexture Function


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

Syntax

HRESULT D3DXCreateTexture(      

    LPDIRECT3DDEVICE9 pDevice,     UINT Width,     UINT Height,     UINT MipLevels,     DWORD Usage,     D3DFORMAT Format,     D3DPOOL Pool,     LPDIRECT3DTEXTURE9 *ppTexture );

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device to be associated with the texture.
Width
[in] Width in pixels. If this value is 0, a value of 1 is used. See Remarks.
Height
[in] Height in pixels. If this value is 0, a value of 1 is used. See Remarks.
MipLevels
[in] Number of mip levels requested. If this value is zero or D3DX_DEFAULT, a complete mipmap chain is created.
Usage
[in] 0, D3DUSAGE_RENDERTARGET, or D3DUSAGE_DYNAMIC. Setting this flag to D3DUSAGE_RENDERTARGET indicates that the surface is to be used as a render target. The resource can then be passed to the pNewRenderTarget" parameter of the IDirect3DDevice9::SetRenderTarget method. If either D3DUSAGE_RENDERTARGET or D3DUSAGE_DYNAMIC is specified, the application should check that the device supports this operation by calling IDirect3D9::CheckDeviceFormat. For more information about using dynamic textures, see Using Dynamic Textures.
Format
[in] Member of the D3DFORMAT enumerated type, describing the requested pixel format for the texture. The returned texture may be 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] Member of the D3DPOOL enumerated type, describing the memory class into which the texture should be placed.
ppTexture
[out] Address of a pointer to an IDirect3DTexture9 interface, representing the created texture object.

Return Value

If the function succeeds, the return value is D3D_OK.

If the function fails, the return value can be one of the following values.

D3DERR_NOTAVAILABLEThis device does not support the queried technique.
D3DERR_OUTOFVIDEOMEMORYMicrosoft?Direct3D?does not have enough display memory to perform the operation.
D3DERR_INVALIDCALLThe method call is invalid. For example, a method's parameter may have an invalid value.
E_OUTOFMEMORYDirect3D could not allocate sufficient memory to complete the call.


Remarks

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

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

Function Information

Headerd3dx9tex.h
Import libraryd3dx9.lib
Minimum operating systems Windows 98

See Also

Texture Color Conversions


© 2002 Microsoft Corporation. All rights reserved.