Primitive Types (Windows Embedded CE 6.0)
1/6/2010
Microsoft® Direct3D® Mobile uses a number of different primitive types. An application may use any type of supported primitive at any time. The primitive type is passed as a parameter to the IDirect3DMobileDevice::DrawPrimitive and IDirect3DMobileDevice::DrawIndexedPrimitive methods. To draw multiple primitive types the application must call a drawing function multiple times. An application can have data for multiple primitive types in the vertex buffer at the same time. An application can also use the same vertex data in different primitive types across multiple drawing calls.
The following table shows the types of primitives that Direct3D Mobile supports.
Primitive Type | D3DMPRIMITIVETYPE value |
---|---|
Point List |
D3DMPT_POINTLIST |
Line List |
D3DMPT_LINELIST |
Line Strip |
D3DMPT_LINESTRIP |
Triangle List |
D3DMPT_TRIANGLELIST |
Triangle Strip |
D3DMPT_TRIANGLESTRIP |
Triangle Fan |
D3DMPT_TRIANGLEFAN |
The vertices that are used for each primitive are read from the active vertex buffer. The IDirect3DMobileDevice::DrawPrimitive method has a parameter that is the offset of the first vertex to use, and then vertices are read consecutively after that. The IDirect3DMobileDevice::DrawPrimitive method also has a parameter that specifies the number of primitives to draw. If there are not enough vertices available in the vertex buffer to draw a primitive, then the primitive is not drawn, and command processing continues.
If there is no active vertex buffer when a IDirect3DMobileDevice::DrawPrimitive command is processed, a D3DMERR_DRIVERINTERNALERROR error is set, and command processing continues.
Point List
The point list primitive treats each vertex as an individual point. Once the point is transformed, it is rasterized as a single pixel. The point rasterization rules define this behavior. Each point primitive consists of a single vertex. If there are vertices A, B, C, and D, then 4 point primitives will be drawn, as defined by A, B, C, and D.
Line List
The line list primitive specifies a series of independent line segments. Each primitive consists of two vertices. The primitive is rasterized according to the line rasterization rules. If there are vertices A, B, C and D, then 2 line segments will be drawn, as defined by (A, B) and (C, D).
Line Strip
The line strip primitive specifies a series of interconnected line segments. The first two vertices specify a line segment in the same way as the line list primitive. However, each additional vertex is treated as the endpoint of another line segment with the vertex preceding it. Therefore, if there are vertices A, B, C and D, three line segments will be drawn as defined by (A,B), (B,C) and (C,D).
Triangle List
The triangle list primitive specifies a series of independent triangles. Each primitive consists of three vertices, and is drawn according to triangle rasterization rules. If there are vertices A, B, C, D, E and F, then 2 triangles will be drawn (A,B,C) and (D,E,F).
Triangle Strip
The triangle strip primitive specifies a series of interconnected triangles. The first triangle is specified according to the first 3 vertices as in a triangle list. The remaining triangles are specified by a shared edge with the previous triangle and one new vertex. If there are vertices A, B, C, D, E, and F, then 4 triangles will be drawn: (A,B,C), (B, D, C), (C, D, E), and (D, F, E). Note that the second and third vertices of the second and fourth triangles are reversed. The triangles (B, D, C) and (D, F, E) are used rather than (B, C, D) and (D, E, F) to preserve the "winding order" of the triangles. All of the triangles a strip are wound in the same direction.
Triangle Fan
The triangle fan primitive also specifies a series of interconnected triangles. Like the triangle strip, the first triangle is specified by the first 3 vertices. Each successive vertex is moved into the third vertex position and the vertex that was in the third position is moved into the second. The first vertex never changes. If there are vertices A, B, C, D, E, and F, then 4 triangles will be drawn: (A, B, C), (A, C, D), (A, D, E) and (A, E, F). All triangles are drawn using the triangle rasterization rules.