Platform SDK: DirectX
Rendering Strided Vertices  [Visual Basic]

Note  The information in this topic applies only to applications written in C++. DirectX for Visual Basic does not support rendering with strided vertices.

[C++]

Because of the indirection provided by strided vertices—detailed in the Strided Vertex Format section—applications must take care to set up the vertices properly. Often, developers forget to include a vertex component in the associated D3DDRAWPRIMITIVESTRIDEDDATA structures. This oversight doesn't necessarily cause the rendering methods to fail, but can result in "missing" geometry that is difficult to troubleshoot.

The following code shows one way that you might set up and render strided vertices.

//---------------------------------------------
// A custom vertex format that includes XYZ, a
// diffuse color & two sets of texture coords.
//---------------------------------------------
struct MTVERTEX
{
    FLOAT x, y, z;
    DWORD dwColor;
    FLOAT tuBase, tvBase;
    FLOAT tuLightMap, tvLightMap;
};
 
// Make an array of custom vertices.
MTVERTEX g_avVertices[36];
// Fill the array.
//  (vertex at index 0)
//  .
//  .
//  .
//  (vertex at index 35)
 
// Construct strided vertices vertex using the array of
// custom vertices already defined.
D3DDRAWPRIMITIVESTRIDEDDATA g_StridedData;
 
// Assign the addresses of the various interleaved components 
// to their corresponding strided members.
g_StridedData.position.lpvData          = &g_avWallVertices[24].x;
g_StridedData.diffuse.lpvData           = &g_avWallVertices[24].dwColor;
g_StridedData.textureCoords[0].lpvData  = &g_avWallVertices[24].tuBase;
g_StridedData.textureCoords[1].lpvData  = &g_avWallVertices[24].tuLightMap;
g_StridedData.position.dwStride         = sizeof(MTVERTEX);
g_StridedData.diffuse.dwStride          = sizeof(MTVERTEX);
g_StridedData.textureCoords[0].dwStride = sizeof(MTVERTEX);
g_StridedData.textureCoords[1].dwStride = sizeof(MTVERTEX);
 
// Render the vertices with multiple texture blending (Modulate).
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_pd3dDevice->SetTexture( 0, g_BaseTextureMap);
g_pd3dDevice->SetTexture( 1, g_LightMap);
g_pd3dDevice->DrawPrimitiveStrided( D3DPT_TRIANGLELIST,
                        D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX2,
                        &g_StridedData, 12, NULL );