Platform SDK: DirectX

Calling Vertex Buffer Rendering Methods

[C++]

The IDirect3DDevice7::DrawPrimitiveVB method corresponds to the IDirect3DDevice7::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 clip extents during rendering.

The IDirect3DDevice7::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 and fourth parameters should be the index of the first vertex in the buffer and the total number of vertices to be rendered. The fifth 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 sixth 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.

[Visual Basic]

The Direct3DDevice7.DrawPrimitiveVB method corresponds to the Direct3DDevice7.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 d3dpt parameter to indicate the type of primitive being rendered by using one the members of the CONST_D3DPRIMITIVETYPE enumeration. Specify the Direct3DVertexBuffer7 object that contains the vertices in the second parameter, vertexBuffer, then set values in the startVertex and numVertices 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, flags, 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 clip extents during rendering.

The Direct3DDevice7.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 and fourth parameters should be the index of the first vertex in the buffer and the total number of vertices to be rendered. The fifth parameter, indexArray, should be set to the first element in an ordered array of Integer indices that the method will use to access the vertices to be rendered, and the sixth parameter, indexCount, should be to the number of index values that the array contains. The flags 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 or a HAL Device (IID_IDirect3DHALDevice), as opposed to a TnLHAL Device (IID_IDirect3DTnLHALDevice) capable of hardware-accelerated transformation and lighting, can only render from vertex buffers that were created with the D3DVBCAPS_SYSTEMMEMORY flag. For more information, see Device Types and Vertex Processing Requirements.