Microsoft DirectX 8.1 (Visual Basic) |
Before using textures, a custom vertex format that includes texture coordinates must be used. Texture coordinates tells Microsoft® Direct3D® where to place a texture for each vector in a primitive. Texture coordinates range from 0.0 to 1.0, where (0.0, 0.0) represents the top left-hand side of the texture and (1.0, 1.0) represents the bottom right-hand side of the texture.
The following code fragment shows how the Texture sample project sets up it's custom vertex format to include texture coordinates.
' Custom vertex type. Private Type CUSTOMVERTEX postion As D3DVECTOR '3-D position for vertex. color As Long 'Color of the vertex. tu As Single 'Texture map coordinate. tv As Single 'Texture map coordinate. End Type ' Custom FVF. Const D3DFVF_CUSTOMVERTEX = (D3DFVF_XYZ Or D3DFVF_DIFFUSE Or D3DFVF_TEX1)
For more information on texture coordinates, see Texture Coordinates.
Now that a custom vertex type has been defined, the next step is to load a texture and create a cylinder, as described in Step 2: Initializing Screen Geometry.