Flexible Vertex Format Flags
Direct3D Immediate Mode uses flag values to describe vertex formats used for DrawPrimitive-based rendering. The D3dtypes.h header file defines the following flags to explicitly describe a vertex format, and provides helper macros that act as common combinations of such flags. For more information, see About Vertex Formats.
- Flexible vertex format (FVF) flags
- D3DFVF_DIFFUSE
- Vertex format includes a diffuse color component.
- D3DFVF_NORMAL
- Vertex format includes a vertex normal vector. This flag cannot be used with the D3DFVF_XYZRHW flag.
- D3DFVF_SPECULAR
- Vertex format includes a specular color component.
- D3DFVF_XYZ
- Vertex format includes the position of an untransformed vertex. This flag cannot be used with the D3DFVF_XYZRHW flag. If you use this flag, you must also specify a vertex normal, a vertex color component (D3DFVF_DIFFUSE or D3DFVF_SPECULAR), or include at least one set of texture coordinates (D3DFVF_TEX1 through D3DFVF_TEX8).
- D3DFVF_XYZRHW
- Vertex format includes the position of a transformed vertex. This flag cannot be used with the D3DFVF_XYZ or D3DFVF_NORMAL flags. If you use this flag, you must also specify a vertex color component (D3DFVF_DIFFUSE or D3DFVF_SPECULAR) or include at least one set of texture coordinates (D3DFVF_TEX1 through D3DFVF_TEX8).
- Texture-related FVF flags
- D3DFVF_TEX0 through D3DFVF_TEX8
- Number of texture coordinate sets for this vertex. The actual values for these flags are not sequential.
- Helper macros
- D3DFVF_LVERTEX
- Vertex format is equivalent to the D3DLVERTEX vertex type.
- D3DFVF_TLVERTEX
- Vertex format is equivalent to the D3DTLVERTEX vertex type.
- D3DFVF_VERTEX
- Vertex format is equivalent to the D3DVERTEX vertex type.
- Mask values
- D3DFVF_POSITION_MASK
- Mask for position bits.
- D3DFVF_RESERVED0 and D3DFVF_RESERVED2
- Mask values for reserved bits in the flexible vertex format. Do not use.
- D3DFVF_RESERVED1,
- This bit is reserved to indicate that the system should emulate D3DLVERTEX processing. If this flag is used, the D3DFVF_XYZ, D3DFVF_DIFFUSE, D3DFVF_SPECULAR, and D3DFVF_TEX1 flags must also be used. This equates to the effect of the D3DFVF_LVERTEX helper macro.
- D3DFVF_TEXCOUNT_MASK
- Mask value for texture flag bits.
- Miscellaneous
- D3DFVF_TEXCOUNT_SHIFT
- The number of bits to shift an integer value that identifies the number of a texture coordinates for a vertex. This value might be used as follows:
DWORD dwNumTextures = 1; // vertex has only one set of coordinates
// Shift the value for use when creating an FVF combination.
dwFVF = dwNumTextures<<D3DFVF_TEXCOUNT_SHIFT;
/*
* Now, create an FVF combination using the shifted value.
*/
The following example shows some other common flag combinations:
// Lightweight, untransformed vertex for lit, untextured,
// Gouraud-shaded content.
dwFVF = ( D3DFVF_XYZ | D3DFVF_DIFFUSE );
// Untransformed vertex for unlit, untextured, Gouraud-shaded
// content with diffuse material color specified per vertex.
dwFVF = ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE );
// Untransformed vertex for light-map based lighting.
dwFVF = ( D3DFVF_XYZ | D3DFVF_TEX2 );
// Transformed vertex for light-map based lighting
// with shared rhw.
dwFVF = ( D3DFVF_XYZRHW | D3DFVF_TEX2 );
// Heavyweight vertex for unlit, colored content with two
//sets of texture coordinates.
dwFVF = ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE |
D3DFVF_SPECULAR | D3DFVF_TEX2 );