A triangle fan is similar to a triangle strip, except that all of the triangles share one vertex, as shown in the following illustration.
The system uses vertices v2, v3, and v1 to draw the first triangle, v3, v4, and v1 to draw the second triangle, v4, v5, and v1 to draw the third triangle, and so on. (When flat shading is enabled, the system shades the triangle with the color from its first vertex.)
Your application can create a triangle fan by filling an array of vertices, as shown in the following code fragment:
const DWORD TOTAL_VERTS=6;
D3DVERTEX lpVerts[TOTAL_VERTS];
lpVerts[0] = D3DVERTEX(D3DVECTOR(0,0,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[1] = D3DVERTEX(D3DVECTOR(-5,-5,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[2] = D3DVERTEX(D3DVECTOR(-3,7,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[3] = D3DVERTEX(D3DVECTOR(0,10,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[4] = D3DVERTEX(D3DVECTOR(3,7,0),D3DVECTOR(0,0,-1),0,0);
lpVerts[5] = D3DVERTEX(D3DVECTOR(5,5,0),D3DVECTOR(0,0,-1),0,0);
It can then render the triangle fan using the IDirect3DDevice3::DrawPrimitive method. The following code fragment illustrates the use of IDirect3DDevice3::DrawPrimitive for drawing the triangle fan 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_TRIANGLEFAN,
D3DFVF_VERTEX,
lpVerts,
TOTAL_VERTS,
D3DDP_WAIT);
This illustration depicts the resulting triangle fan.