A version of this page is also available for

Windows Embedded CE 6.0 R3


This method is used to change the current texture map bound to texture stage.


HRESULT SetTexture(
  DWORD Stage,
  IDirect3DMobileBaseTexture* pTexture


  • Stage
    [in] Stage identifier of the texture to retrieve. Stage identifiers are zero-based. The maximum number of texture stage states is defined in D3DM_TEXSTAGECOUNT and the number of texture stages supported by the device is in D3DMCAPS as MaxTextureBlendStages.
  • pTexture
    [in] A pointer to an IDirect3DMobileBaseTexture interface for the texture that will be bound to the stage identified by Stage.

    The IDirect3DMobileDevice::SetTexture method maintains a reference to the texture map's interface so long as the texture map is bound to the stage. Setting this parameter to NULL clears the texture map currently bound to a stage.

Return Value

If the method succeeds, the return value is D3DM_OK (see D3DM Values).

If the method fails, the return value can be D3DMERR_INVALIDCALL (see D3DMERR Values).


There are no default texture maps in Direct3D Mobile, and nothing is automatically bound to any texture stage.

This method increments the reference count of the texture surface being assigned and decrements the reference count of the previously selected texture if there is one. When the texture is no longer needed, set the texture at the appropriate stage to NULL. Failure to do this results in a memory leak.


Header d3dm.h
Library D3dm.lib, D3dmguid.lib
Windows Embedded CE Windows CE 5.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also