concept TriangleList in category silverlight

appears as: TrigleList
Silverlight 5 in Action

This is an excerpt from Manning's book Silverlight 5 in Action.

This line is the critical part of the Draw method—it’s the only way that the graphics device knows how to render the vertices. The call passed the points in to the DrawPrimitives method, telling it to treat the points as a TriangleList starting at the first (zero) item in the buffer and continuing for one triangle (three vertices). What exactly is a triangle list, and what’s a primitive anyway? I’ll answer that question in the next section.

Most shapes you could want can be represented by a set of connected triangles. The TriangleList is the easiest way to represent all of those individual triangles. In a triangle list, each and every triangle you want to use is defined by a set of three vertices. So, for a shape made up of 100 triangles, you’ll have 300 vertex entries. This is true even in the very common case of a connected strip of triangles where each triangle shares two points with the previous triangle in the strip.

You can see an example of a TriangleList with one triangle by looking at the code that rendered the SimpleTriangle. The call to DrawPrimitives tells the rendering system that for this array of vertices, treat it as individual triangles.

Device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

In this case, it says to start at vertex 0 and read for 1 triangle. Silverlight, because the TriangleList primitive is specified, will expect to see 3 vertices defined in the list. If you don’t have at least 3 in there, you’ll get a runtime error.

So, the TriangleList (and the other primitives) aren’t real types in the .NET sense. They’re a specification that tells the rendering system how to treat an otherwise arbitrary array of vertices.