A triangle strip is a series of connected triangles. Because the triangles are connected, the application does not need to repeatedly specify all three vertices for each triangle. For example, you only need seven vertices to define the following triangle strip.
The system uses vertices v1, v2, and v3 to draw the first triangle, v2, v4, and v3 to draw the second triangle, v3, v4, and v5 to draw the third, v4, v6, and v5 to draw the fourth, and so on. Notice that the vertices of the second and fourth triangles are out of order; this is required to make sure that all of the triangles are drawn in a clockwise orientation.
Most objects in 3-D scenes are composed of triangle strips. This is because triangle strips can be used to specify complex objects in a way that makes efficient use of memory and processing time. Triangle strips are also much easier to use than the D3DTRIANGLE structure that is used in conjunction with execute buffers.
Create a triangle strip by filling an array of vertices, as in the following code fragment:
const DWORD TOTAL_VERTS=6;
D3DVERTEX lpVerts[TOTAL_VERTS];
lpVerts[0] = D3DVERTEX(D3DVECTOR(-5,-5,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[1] = D3DVERTEX(D3DVECTOR(0,5,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[2] = D3DVERTEX(D3DVECTOR(5,-5,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[3] = D3DVERTEX(D3DVECTOR(10,5,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[4] = D3DVERTEX(D3DVECTOR(15,-5,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[5] = D3DVERTEX(D3DVECTOR(20,5,0),D3DVECTOR(0,0,-1),0,0);
Your application can then render the triangle strip using the IDirect3DDevice3::DrawPrimitive method. The following code fragment illustrates the use of IDirect3DDevice3::DrawPrimitive for drawing the triangle strip in the preceding example. Remember that all calls to IDirect3DDevice3::DrawPrimitive must occur between IDirect3DDevice3::BeginScene and IDirect3DDevice3::EndScene.
HRESULT hResult;
// This code fragment assumes that lpDirect3DDevice3 is a valid
// pointer to an IDirect3DDevice3 interface.
hResult =
lpDirect3DDevice3 ->DrawPrimitive(D3DPT_TRIANGLESTRIP,
D3DFVF_VERTEX,
lpVerts,
TOTAL_VERTS,
D3DDP_WAIT);
The following illustration shows the resulting triangle strip.