Calling Vertex Buffer Rendering Methods

The IDirect3DDevice3::DrawPrimitiveVB method corresponds to the IDirect3DDevice3::DrawPrimitive method. Like its relative, the DrawPrimitiveVB method assumes that vertices appear in sequential order within the vertex buffer.

The DrawPrimitiveVB method accepts five parameters. Set the d3dptPrimitiveType parameter to indicate the type of primitive being rendered by using one the members of the D3DPRIMITIVETYPE enumerated type. Specify the address of the vertex buffer that contains the vertices in the second parameter, lpd3dVertexBuffer, then set values in the dwStartVertex and dwNumVertices parameters to reflect the first vertex and the total number of vertices that will be rendered. You don't need to render all the vertices that the vertex buffer contains, but you must use the appropriate number of vertices for that primitive type (as documented in the reference information for D3DPRIMITIVETYPE). The last parameter, dwFlags, determines the rendering behavior. These flags are identical to those used with other rendering methods. You can set flags to enable lighting and clipping, or to update the viewport extents during rendering.

The IDirect3DDevice3::DrawIndexedPrimitiveVB method renders primitives by indexing the vertices within a vertex buffer. The first two parameters are identical to those of the DrawPrimitiveVB method. The third parameter, lpwIndices, should be set to the address of an ordered array of WORD indices that the method will use to access the vertices to be rendered, and the fourth parameter, dwIndexCount, should be set to the number of index values that the array contains. The dwFlags parameter is identical to its counterpart in the DrawPrimitiveVB method.

You cannot request that vertex buffer rendering methods perform lighting if the format of the vertices within the buffer does not contain a vertex normal. Nor can you request that the rendering methods clip vertices when rendering from a transformed vertex buffer created with the D3DDP_DONOTCLIP flag. (This is allowed for untransformed vertex buffers, as the system will create a clipping-capable version at render time.) Attempts to request unavailable services will not cause the method to fail in debug builds, but the services will not be applied.

A software device, as opposed to a hardware-accelerated device, can only render from vertex buffers that were created with the D3DVBCAPS_SYSTEMMEMORY flag. For more information, see Vertex Buffers and Device Types.