DirectX SDK

Rendering with Texture Surfaces

Direct3D supports multiple texture blending through the concept of texture stages. Each texture stage contains a texture and operations that can be performed on the texture. The textures in the texture stages form the set of current textures. For more information, see Multiple Texture Blending. The state of each texture is encapsulated in its texture stage.

[C++]

In a C++ application, the state of each texture must be set with the IDirect3DDevice7::SetTextureStageState method. Pass the stage number (0-7) as the value of the first parameter. Set the value of the second parameter to a member of the member of the D3DTEXTURESTAGESTATETYPE enumerated type. The final parameter is the state value for the particular texture state.

Using texture interface pointers, your application can render a blend of up to eight textures. Set the current textures by invoking the IDirect3DDevice7::SetTexture method. Direct3D will blend all current textures onto the primitives that it renders.

Note  The SetTexture method increments the reference count of the texture surface being assigned. When the texture is no longer needed, you should set the texture at the appropriate stage to NULL. If you fail to do this, the surface will not be released, resulting in a memory leak.

Your application can set the texture wrapping state for the current textures by calling the IDirect3DDevice7::SetRenderState method. Pass a value from D3DRENDERSTATE_WRAP0 through D3DRENDERSTATE_WRAP7 as the value of the first parameter, and use a combination of the D3DWRAPCOORD_0, D3DWRAPCOORD_1, D3DWRAPCOORD_2, and D3DWRAPCOORD_3 flags to enable wrapping in the u or v directions.

Your application can also set the texture perspective and texture filtering states. See Texture Perspective State, Texture Filtering, and Texture Filtering State.

[Visual Basic]

From Visual Basic, the state of each texture must be set with the Direct3DDevice7.SetTextureStageState method. Pass the stage number (0-7) as the value of the first parameter. Set the value of the second parameter to a member of the member of the CONST_D3DTEXTURESTAGESTATETYPE enumeration. The final parameter is the state value for the particular texture state.

Applications can render a blend of up to eight textures. Set the current textures by invoking the Direct3DDevice7.SetTexture method. Direct3D will blend all current textures onto the primitives that it renders.

Note  When the texture is no longer needed, you should set the texture at the appropriate stage to Nothing. If you fail to do this, the memory for the surface may be lost when your application closes.

Your application can set the texture wrapping state for the current textures by calling the Direct3DDevice7.SetRenderState method. Pass a value from D3DRENDERSTATE_WRAP0 through D3DRENDERSTATE_WRAP7 as the value of the first parameterand use a combination of the D3DWRAPCOORD_0, D3DWRAPCOORD_1, D3DWRAPCOORD_2, and D3DWRAPCOORD_3 flags (from the CONST_D3D enumeration) to enable wrapping in the u or v directions.

Your application can also set the texture perspective and texture filtering states. See Texture Perspective State, Texture Filtering, and Texture Filtering State.