Strided Vertex Format

The strided vertex format contains fields to represent untransformed vertices, lit or unlit, for the IDirect3DDevice3::DrawPrimitiveStrided and IDirect3DDevice3::DrawIndexedPrimitiveStrided methods. You cannot use the strided vertex format for transformed vertices. Unlike a "normal" vertex, which is a structure that physically contains all the necessary vertex components, a "strided" vertex is a structure that contains pointers to the vertex components rather than the components themselves.

This indirection is accomplished through the D3DDRAWPRIMITIVESTRIDEDDATA structure that is accepted by the DrawPrimitiveStrided and DrawIndexedPrimitiveStrided methods. You describe strided vertices using the same combinations of flexible vertex format flags as a non-strided vertex. However, unlike non-strided vertices, the flags you use do not indicate the presence of a given field in memory (D3DDRAWPRIMITIVESTRIDEDDATA includes them all), they indicate which the structure members that your application uses. The restrictions for these flags are identical to non-strided vertices, for details, see Flexible Vertex Format Flags.

The D3DDRAWPRIMITIVESTRIDEDDATA structure contains 12 D3DDP_PTRSTRIDE structures, one structure each for the position, normal, diffuse color, specular color, and texture coordinate sets for the vertices. Each D3DDP_PTRSTRIDE structure contains a pointer to an array of data, and the stride of that array. These 12 structures provide the indirection that allows your application to arrange vertex components however it needs. For instance, you might use distinct arrays for every vertex component, as shown in the following illustration.

The lpvData member of the corresponding D3DDP_PTRSTRIDE structures contains the address of a buffer that contains an array of vertex components. Each element in each array represents a component for one vertex, which is made up of some number of floats (for position, normal, and texture coordinates) or an RGBA value (for diffuse and specular colors). There is one entry within each array for every vertex to be rendered. The dwStride member of D3DDP_PTRSTRIDE should be set to the memory stride, in bytes, from one entry in the array to the next. The following table describes the components and the corresponding strides for each.

Component Stride
untransformed position 3 floats (x,y,z)
vertex normal 3 floats (nx,ny,nz)
diffuse color 1 DWORD (RGBA)
specular color 1 DWORD (RGBA)
texture coordinate set 2 floats (u,v)

Some developers might choose to include some or all vertex components in an interleaved array. The strided vertex format makes doing this very simple. If your application interleaves the vertex position and normal components, for example, you could visualize the memory layout and corresponding settings in D3DDP_PTRSTRIDE structures as follows:

In this case, the lpvData members of the D3DDP_PTRSTRIDE structures point to two locations within the same buffer, and the strides are set to the combined width of the interleaved components. Of course, you aren't limited to any particular interleaving scheme. So long as you set the data pointers and their strides correctly, any interleaving scheme will work.