DirectX 11 & DrawIndexed()

B24044bda718c3a3fc73ea9b2ead04a4
0
kurlyak 101 Dec 29, 2011 at 12:00

I have some code and it wrong. If it not hard please correct my code. I dont understand where and what a value must set. In my code attribute are ordered by index (from 0 to last).

for(UINT i=0; i<pFrame->pMeshContainer->nNumMat; i++)
{
.......................................
UINT nIndxCount = pFrame->pMeshContainer->atr[i].FaceCount * 3;
UINT nStartIndexLocation = pFrame->pMeshContainer->atr[i].FaceStart * 3;
UINT nBaseVertLocation = pFrame->pMeshContainer->atr[i].VertexStart;
UINT stride = sizeof( MY_VERTEX );
UINT offset = 0;
m_pImmediateContext->IASetVertexBuffers( 0, 1, &(pFrame->pMeshContainer->pVB), &stride, &offset );
m_pImmediateContext->IASetIndexBuffer( pFrame->pMeshContainer->pIB, DXGI_FORMAT_R32_UINT, 0 );
   
m_pImmediateContext->DrawIndexed(nIndxCount,0, nStartIndexLocation );
  }

Thanks in advance.

5 Replies

Please log in or register to post a reply.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 104 Dec 29, 2011 at 15:15

you havent set the primitive topology, for one thing, try that…
dc->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

B24044bda718c3a3fc73ea9b2ead04a4
0
kurlyak 101 Dec 29, 2011 at 16:36

Thank you for your reply. But I dont show all my code. I included primitive topology earlier. In this case, I ask only about the indices and the vertices and DrawIndexed(). My Primitive Topoligy is Trianglelist.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Dec 29, 2011 at 18:46

Shouldn’t it be DrawIndexed(nIndxCount, nStartIndexLocation, 0)? The second parameter is the start index location, and the third parameter is a vertex offset. See the docs.

B24044bda718c3a3fc73ea9b2ead04a4
0
kurlyak 101 Dec 29, 2011 at 19:31

You are god of this forum! Great thanks, Reedbeta!

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 104 Dec 29, 2011 at 21:19

he is indeed. :)