Platform SDK: DirectX

Direct3DDevice7.DrawIndexedPrimitive

The Direct3DDevice7.DrawIndexedPrimitive method renders the specified geometric primitive based on indexing into an array of vertices.

object.DrawIndexedPrimitive( _ 
    d3Dpt As CONST_D3DPRIMITIVETYPE, _ 
    d3dfvf As CONST_D3DFVFFLAGS, _ 
    vertices As Any, _ 
    vertexCount As Long, _ 
    indices() As Integer, _ 
    IndicesCount As Long, _ 
    flags As CONST_D3DDPFLAGS)

Parameters

object
Object expression that resolves to a Direct3DDevice7 object.
d3Dpt
Type of primitive to be rendered by this command. This must be one of the constants of the CONST_D3DPRIMITIVETYPE enumeration.

Note that the D3DPT_POINTLIST member of CONST_D3DPRIMITIVETYPE is not indexed.

d3dfvf
A combination of flexible vertex format flags from the CONST_D3DFVFFLAGS enumeration that describe the vertex format used.
vertices
First element in an array of vertices to be used in the primitive sequence.
vertexCount
Defines the number of vertices in the vertices array.

Notice that this parameter is used differently from the vertexCount parameter in the Direct3DDevice7.DrawPrimitive method. In that method, the vertexCount parameter gives the number of vertices to draw, but here it gives the total number of vertices in the array pointed to by the vertices parameter. When you call Direct3DDevice7.DrawIndexedPrimitive, you specify the number of vertices to draw in the IndicesCount parameter.

indices()
Array that is to be used to index into the specified vertex list when creating the geometry to render. The values in the array must index vertices within the range [0, dwNumVertices – 1].
IndicesCount
Specifies the number of indices provided for creating the geometry. The maximum number of indices allowed is 65535 (&HFFFF).
flags
One of the constants from the CONST_D3DDPFLAGS defining how the primitive is drawn.

Error Codes

If the method fails, an error is raised and Err.Number may be set to one of the following values:

D3DERR_INVALIDRAMPTEXTURE
D3DERR_INVALIDPRIMITIVETYPE
D3DERR_INVALIDVERTEXTYPE
DDERR_WASSTILLDRAWING
DDERR_INVALIDPARAMS

For information on trapping errors, see the Visual Basic Error Trapping topic.

Remarks

Make sure that the vertices being rendered match the vertex format you specify. For performance reasons, Direct3D does not attempt to verify that vertex size and stride match the provided flexible vertex format. If a mismatch occurs, a memory fault is likely to result.

This method should not be used when rendering from a vertex buffer, use a vertex buffer method instead.

In current versions of DirectX, Direct3DDevice7.DrawIndexedPrimitive can sometimes generate an update rectangle that is larger than it strictly needs to be. If a large number of vertices need to be processed, this can have a negative impact on the performance of your application. If you are using D3DTLVERTEX vertices and the system is processing more vertices than you need, you should use the D3DDP_DONOTCLIP and D3DDP_DONOTUPDATEEXTENTS flags to solve the problem.

See Also

Direct3DDevice7.DrawPrimitive, Direct3DDevice7.DrawPrimitiveVB, Direct3DDevice7.DrawIndexedPrimitiveVB