The presence of the D3DFVF_XYZ and D3DFVF_NORMAL flags in the vertex description that you pass to rendering methods identifies the untransformed and unlit vertex type. By using untransformed and unlit vertices, your application effectively requests that Direct3D perform all transformation and lighting operations using its internal algorithms. (If you want, you can pass D3DDP_DONOTLIGHT to the rendering methods to disable Direct3D's lighting engine for the primitives being rendered.)
Most applications use this vertex type, as it frees them from implementing their own transformation and lighting engines. However, because the system is making calculations for you, it requires that you provide a certain amount of information with each vertex:
Other than these requirements, you have the flexibility to use (or disregard) the other vertex components. For example, if you want to include a diffuse or specular color with your untransformed vertices, you can. (This wasn't possible before DirectX 6.0). These color components can "tint" the material color at each vertex, making it possible to achieve shading effects that are much more subtle and flexible than lighting calculations that use only the material color. Untransformed, unlit vertices can also include up to eight sets of texture coordinates.
Applications can still use the legacy D3DVERTEX structure for vertices. In fact, the d3dtypes.h header file defines a shortcut macro to identify this vertex format:
#define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )
If the D3DVERTEX structure doesn't suit your application's needs, feel free to define your own. Remember which vertex components your application needs, and make sure they appear in the required order by declaring a properly ordered structure. The following code declares a valid vertex format structure that includes a position, a vertex normal, a diffuse color, and two sets of texture coordinates:
//
// The vertex format description for this vertex
// would be: (D3DFVF_XYZ | D3DFVF_NORMAL |
// D3DFVF_DIFFUSE | D3DFVF_TEX2)
//
typedef struct _UNLITVERTEX {
float x, y, z; // position
float nx, ny, nz; // normal
DWORD dwDiffuseRGBA; // diffuse color
float tu1, // texture coordinates
tv1;
float tu2,
tv2;
} UNLITVERTEX, *LPUNLITVERTEX;
The vertex description for the preceding structure would be a combination of the D3DFVF_XYZ, D3DFVF_NORMAL, D3DFVF_DIFFUSE, and D3DFVF_TEX2 flexible vertex format flags. The rendering methods, such as IDirect3DDevice3::DrawPrimitive, accept the address of a vertex array as a void pointer, so remember to cast your vertex array pointer to the LPVOID data type when you call the rendering methods.
For more information, see About Vertex Formats.