1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| void SubMesh::SetIndices(const std::vector<int> &_a)
{
VOID* pBufferIndices ;
WORD* pIndices = new WORD[m_dwNumOfIndices] ;
//Create the index buffer from the device
if(m_pD3DDevice)
{
m_pD3DDevice->CreateIndexBuffer(m_dwNumOfIndices * sizeof(WORD),
0 , D3DFMT_INDEX16, D3DPOOL_MANAGED,
&m_pIndexBuffer, NULL) ;
}
//Set values for the index buffer
for(int i=0 ; i<_a.size() ; i++)
{
pIndices[i] = _a[i] ;
}
//Get a pointer to the index buffer indices and lock the index buffer
m_pIndexBuffer->Lock(0, m_dwNumOfIndices * sizeof(WORD), (void**)&pBufferIndices, 0);
//Copy our stored indices values into the index buffer
memcpy(pBufferIndices, pIndices, m_dwNumOfIndices * sizeof(WORD));
//Unlock the index buffer
m_pIndexBuffer->Unlock();
} |
Partager