Export (0) Print
Expand All

ID3DX10Mesh::DrawSubsetInstanced method

Draw several instances of the same subset of a mesh.


HRESULT DrawSubsetInstanced(
  [in] UINT AttribId,
  [in] UINT InstanceCount,
  [in] UINT StartInstanceLocation


AttribId [in]

Type: UINT

Specifies which subset of the mesh to draw. This value is used to differentiate faces in a mesh as belonging to one or more attribute groups. See remarks.

InstanceCount [in]

Type: UINT

Number of instances to render.

StartInstanceLocation [in]

Type: UINT

Which instance to start fetching from in each buffer marked as instance data.

Return value


The return value is one of the values listed in Direct3D 10 Return Codes.


A mesh contains an attribute table. The attribute table can divide a mesh into subsets, where each subset is identified with an attribute ID. For example, a mesh with 200 faces, divided into three subsets, might have an attribute table that looks like this:

AttribID 0Faces 0 ~ 50
AttribID 1Faces 51 ~ 125
AttribID 2Faces 126 ~ 200


Instancing may extend performance by reusing the same geometry to draw multiple objects in a scene. One example of instancing could be to draw the same object with different positions and colors. Indexing requires multiple vertex buffers: at least one for per-vertex data and a second buffer for per-instance data.

Drawing instances with DrawSubsetInstanced is very similar to the process used with ID3D10Device::DrawIndexedInstanced that is outlined in Instancing Sample. The key difference when using DrawSubsetInstanced is that vertex and index buffers must be extracted from the ID3DX10Mesh Interface object before the instancing data can be combined.

The following code illustrates extracting the vertex and index buffers from the mesh object.

      ID3D10Buffer* vertexBuffer;
      pDeviceObj->pMesh->GetDeviceVertexBuffer(0, &vertexBuffer);
      ID3D10Buffer* indexBuffer;






See also

D3DX Interfaces



Community Additions

© 2015 Microsoft