# DirectX 11 & DrawIndexed()

5 replies to this topic

### #1kurlyak

Member

• Members
• 93 posts

Posted 29 December 2011 - 12:00 PM

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 );
}


### #2rouncer

Senior Member

• Members
• 2725 posts

Posted 29 December 2011 - 03:15 PM

you havent set the primitive topology, for one thing, try that...
dc->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #3kurlyak

Member

• Members
• 93 posts

Posted 29 December 2011 - 04:36 PM

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.

### #4Reedbeta

DevMaster Staff

• 5311 posts
• LocationSanta Clara, CA

Posted 29 December 2011 - 06:46 PM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

### #5kurlyak

Member

• Members
• 93 posts

Posted 29 December 2011 - 07:31 PM

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

### #6rouncer

Senior Member

• Members
• 2725 posts

Posted 29 December 2011 - 09:19 PM

he is indeed.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users