Microsoft DirectX 9.0

Triangle Lists

A triangle list is a list of isolated triangles. They might or might not be near each other. A triangle list must have at least three vertices. The total number of vertices must be divisible by three.

Use triangle lists to create an object that is composed of disjoint pieces. For instance, one way to create a force-field wall in a 3-D game is to specify a large list of small, unconnected triangles. Then apply a material and texture that appears to emit light to the triangle list. Each triangle in the wall appears to glow. The scene behind the wall becomes partially visible through the gaps between the triangles, as a player might expect when looking at a force field.

Triangle lists are also useful for creating primitives that have sharp edges and are shaded with Gouraud shading. See Face and Vertex Normal Vectors.

The following illustration depicts a rendered triangle list.

Rendered triangle list

The following code shows how to create vertices for this triangle list.

    float x,y,z;

CUSTOMVERTEX Vertices[] = 
    {-5.0, -5.0, 0.0},
    { 0.0,  5.0, 0.0},
    { 5.0, -5.0, 0.0},
    {10.0,  5.0, 0.0},
    {15.0, -5.0, 0.0},
    {20.0,  5.0, 0.0}


The code example below shows how to use IDirect3DDevice9::DrawPrimitive to render this triangle list.

// It is assumed that d3dDevice is a valid
// pointer to a IDirect3DDevice9 interface.
d3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 2 );

© 2002 Microsoft Corporation. All rights reserved.