Platform SDK: DirectX

About Vertex Formats

Direct3D Immediate Mode applications can define model vertices in several different ways. Support for flexible vertex definitions (also known as "flexible vertex formats") makes it possible for your application to use only the vertex components it needs, eliminating those components that aren't used. By using only the needed vertex components, your application can conserve memory and minimize the processing bandwidth required to render models. You describe how your vertices are formatted by using a combination of flexible vertex format flags.

[C++]

The rendering methods of the IDirect3DDevice7 interface presents C++ applications with methods that accept a combination of these flags, and uses them to determine how to render primitives. Basically, these flags tell the system which vertex components—position, vertex blending weights, normal, colors, the number and format of texture coordinates—your application uses and, indirectly, which parts of the rendering pipeline you want Direct3D to apply to them. In addition, the presence or absence of a particular vertex format flag communicates to the system which vertex component fields are present in memory, and which you've omitted.

To determine device limitations, you can query a device for the D3DFVFCAPS_DONOTSTRIPELEMENTS and D3DFVFCAPS_TEXCOORDCOUNTMASK flexible vertex format flags. For more information, see the dwFVFCaps member of the D3DDEVICEDESC7 structure.

Note  The behavior is slightly different if your application uses the IDirect3DDevice7::DrawPrimitiveStrided or IDirect3DDevice7::DrawIndexedPrimitiveStrided methods. For more information, see Strided Vertex Format.

One significant requirement that the system places on how you format your vertices is on the order in which the data appears. The following illustration depicts the required order for all possible vertex components in memory, and their associated data types.

Note  In DirectX 7.0, texture coordinates can be declared in different formats, allowing textures to be addressed using as few as one coordinate, or as many as three texture coordinates (for 2-D projected texture coordinates). For more information, see Texture Coordinate Formats. Use the D3DFVF_TEXCOORDSIZEn set of macros to create bit patterns that identify the texture coordinate formats that your vertex format uses.

No real application will use every single component—the RHW (reciprocal homogenous W) and vertex normal fields are mutually exclusive–nor will most applications try to use all eight sets of texture coordinates, but the flexibility is there. There are several restrictions on which flags you can use with other flags. These are mostly common sense. For example, you can't use the D3DFVF_XYZ and D3DFVF_XYZRHW flags together, as this would indicate that your application is describing a vertex's position with both untransformed and transformed vertices. For more information, take a look at the description for each of the flags in Flexible Vertex Format Flags.

[Visual Basic]

The Direct3DDevice7 Visual Basic class includes methods that accept a combination of these flags, and uses them to determine how to render primitives. Basically, these flags tell the system which vertex components—position, vertex blending weights, normal, colors, the number and format of texture coordinates—your application uses and, indirectly, which parts of the rendering pipeline you want Direct3D to apply to them. In addition, the presence or absence of a particular vertex format flag communicates to the system which vertex component fields are present in memory, and which you've omitted.

To determine device limitations, you can query a device for the D3DFVFCAPS_DONOTSTRIPELEMENTS and D3DFVFCAPS_TEXCOORDCOUNTMASK flexible vertex format flags. For more information, see the lFVFCaps member of the D3DDEVICEDESC7 type.

One significant requirement that the system places on how you format your vertices is on the order in which the data appears. The following illustration depicts the required order for all possible vertex components in memory, and their associated data types.

Texture coordinates can be declared in different formats, allowing textures to be addressed using as few as one coordinate, or as many as three texture coordinates (for 2-D projected texture coordinates). Use the D3DFVF_TEXCOORDSIZEn set of helper functions from the Math.bas to create bit patterns that identify the texture coordinate formats that your vertex format uses. The Math.bas Visual Basic code module is included with this SDK.

No real application will use every single component—the RHW (reciprocal homogenous W) and vertex normal fields are mutually exclusive–nor will most applications try to use all eight sets of texture coordinates, but the flexibility is there. There are several restrictions on which flags you can use with other flags. These are mostly common sense. For example, you can't use the D3DFVF_XYZ and D3DFVF_XYZRHW flags together, as this would indicate that your application is describing a vertex's position with both untransformed and transformed vertices. For more information, take a look at the description for each of the flags in Flexible Vertex Format Flags.