IDirect3DDevice9::SetStreamSource method (d3d9helper.h)

Binds a vertex buffer to a device data stream. For more information, see Setting the Stream Source (Direct3D 9).

Syntax

HRESULT SetStreamSource(
  [in] UINT                   StreamNumber,
  [in] IDirect3DVertexBuffer9 *pStreamData,
  [in] UINT                   OffsetInBytes,
  [in] UINT                   Stride
);

Parameters

[in] StreamNumber

Type: UINT

Specifies the data stream, in the range from 0 to the maximum number of streams -1.

[in] pStreamData

Type: IDirect3DVertexBuffer9*

Pointer to an IDirect3DVertexBuffer9 interface, representing the vertex buffer to bind to the specified data stream.

[in] OffsetInBytes

Type: UINT

Offset from the beginning of the stream to the beginning of the vertex data, in bytes. To find out if the device supports stream offsets, see the D3DDEVCAPS2_STREAMOFFSET constant in D3DDEVCAPS2.

[in] Stride

Type: UINT

Stride of the component, in bytes. See Remarks.

Return value

Type: HRESULT

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.

Remarks

When a FVF vertex shader is used, the stride of the vertex stream must match the vertex size, computed from the FVF. When a declaration is used, the stride should be greater than or equal to the stream size computed from the declaration.

When calling SetStreamSource, the stride is normally required to be equal to the vertex size. However, there are times when you may want to draw multiple instances of the same or similar geometry (such as when using instancing to draw). For this case, use a zero stride to tell the runtime not to increment the vertex buffer offset (ie: use the same vertex data for all instances). For more information about instancing, see Efficiently Drawing Multiple Instances of Geometry (Direct3D 9).

Requirements

Requirement Value
Target Platform Windows
Header d3d9helper.h (include D3D9.h)
Library D3D9.lib

See also

IDirect3DDevice9

IDirect3DDevice9::DrawIndexedPrimitive

IDirect3DDevice9::DrawIndexedPrimitiveUP

IDirect3DDevice9::DrawPrimitive

IDirect3DDevice9::DrawPrimitiveUP

IDirect3DDevice9::GetStreamSource

Vertex Buffers (Direct3D 9)