DirectX SDK |
The information in this section pertains only to applications written in C and C++. See Direct3D Immediate Mode Visual Basic Tutorials.
The only difference between rendering a textured primitive and a non-textured primitive is that you have to set the texture during the rendering of a textured primitive.
The following code excerpt from the Texture application draws the front and back faces of a cube, using the textured surface g_pddsTexture1:
pd3dDevice->SetTexture( 0, g_pddsTexture1 ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX, g_pCubeVertices+0, 4, NULL ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX, g_pCubeVertices+4, 4, NULL );
The IDirect3DDevice7::SetTexture method assigns a texture to a given stage for the device. Since this tutorial does not use multiple texture blending, the first parameter of SetTexture is 0, specifying a value of 0 for the stage identifier. The second parameter identifies the IDirectDrawSurface7 object being set as the texture.
You should employ the same procedures for the top and bottom faces of the cube, and the left and right faces of the cube, setting g_pddsTexture2 and g_pddsTexture3, respectively. See the Texture application code in the SDK for information on how to do this.
For more information on textured rendering, see Rendering with Texture Surfaces.
For more information on multiple texture blending, see Multiple Texture Blending.