Device.SetStreamSource(Int32,VertexBuffer,Int32) Method (Microsoft.DirectX.Direct3D)
How Do I...?
- Generate a Scene
Binds a vertex buffer to a device data stream.
Definition
Visual Basic Public Sub SetStreamSource( _
ByVal streamNumber As Integer, _
ByVal streamData As VertexBuffer, _
ByVal offsetInBytes As Integer _
)C# public void SetStreamSource(
int streamNumber,
VertexBuffer streamData,
int offsetInBytes
);C++ public:
void SetStreamSource(
int streamNumber,
VertexBuffer^ streamData,
int offsetInBytes
);JScript public function SetStreamSource(
streamNumber : int,
streamData : VertexBuffer,
offsetInBytes : int
);
Parameters
streamNumber System.Int32
Data stream in the range of 0 to the maximum number of streams -1.streamData Microsoft.DirectX.Direct3D.VertexBuffer
Pointer to a VertexBuffer class that represents the vertex buffer to bind to the specified data stream.offsetInBytes System.Int32
Offset from the beginning of the stream to the beginning of the vertex data, in bytes. To determine whether the device supports stream offsets, see DeviceCaps.SupportsStreamOffset.
Remarks
When a flexible vertex format vertex shader is used, the stride of the vertex stream must match the vertex size, computed from the flexible vertex format (FVF). When a declaration is used, the stride should be greater than or equal to the stream size computed from the declaration.
Exceptions
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