Device.DrawPrimitives(PrimitiveType,Int32,Int32) Method (Microsoft.DirectX.Direct3D)

How Do I...?

Renders a sequence of non-indexed geometric primitives of the specified type from the current set of data input streams.

Definition

Visual BasicPublic Sub DrawPrimitives( _
    ByVal primitiveType As PrimitiveType, _
    ByVal startVertex As Integer, _
    ByVal primitiveCount As Integer _
)
C#public void DrawPrimitives(
    PrimitiveType primitiveType,
    int startVertex,
    int primitiveCount
);
C++public:
void DrawPrimitives(
    PrimitiveType primitiveType,
    int startVertex,
    int primitiveCount
);
JScriptpublic function DrawPrimitives(
    primitiveType : PrimitiveType,
    startVertex : int,
    primitiveCount : int
);

Parameters

primitiveType Microsoft.DirectX.Direct3D.PrimitiveType
Member of the PrimitiveType enumerated type that describes the type of primitive to render.
startVertex System.Int32
Index of the first vertex to load. Beginning at param_Int32_startVertex, the correct number of vertices is read out of the vertex buffer.
primitiveCount System.Int32
Number of primitives to render. To determine the maximum number of primitives allowed, check Caps.MaxPrimitiveCount. The param_Int32_primitiveCount is the number of primitives as determined by the primitive type. If it is a line list, each primitive has two vertices. If it is a triangle list, each primitive has three vertices.

Remarks

Device.DrawPrimitives should not be called with a single triangle at a time.

Exceptions
InvalidCallException The method call is invalid. For example, a method's parameter might contain an invalid value.

How Do I...?

Generate a Scene

This example shows how to begin scene generation and draw primitives.

The SetStreamSource method binds a vertex buffer to a device data stream to create an association between the vertex data and one of several data stream ports that feed the primitive processing functions. The parameters for this method are the number of the data stream, the name of the VertexBuffer object, and the stream vertex stride.

In the following C# code example, it is assumed that the device is the rendering Device, and vBuffer is a vertex buffer filled with CustomVertex.PositionNormal data.


              [C#]
              
device.BeginScene();

device.SetStreamSource(0, vBuffer, 0);
device.VertexFormat = CustomVertex.PositionNormal.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

device.EndScene();

See Also

Show: