So my problem is kinda simple. I have a vertex buffer, I create it with
pDevice->CreateVertexBuffer(
m_dwCount * sizeof(CUSTOMVERTEX)),
0,
CUSTOMFVF,
D3DPOOL_MANAGED,
&m_pVB, NULL);
and then let's say for test purposes, I want to modify all of them and multiply them. How exactly can I lock all of them and then multiply them? I tried to lock it
CUSTOMVERTEX* pVoid;
pVB->Lock(0, 0, (void**)&pVoid, 0);
but that I assume doesn't lock the entire buffer. I'm kinda new to the DirectX so I'm sorry if the question is too stupid, however thanks anyone for help.
First create your multiplied vertices (for example called newVertices
). Then you need to lock
your vertex buffer and get the pointer to pointer of current vertices like this :
CUSTOMVERTEX* pVertices;
HRESULT hr = m_pVB->Lock(0, 0, reinterpret_cast<void**>(&pVertices), 0);
Then you can use memcpy
to replace your new vertices into it like this :
if(hr == S_OK)
memcpy(pVertices, newVertices, num_of_vertices * sizeof(CUSTOMVERTEX));
Then unlock
you vertex buffer like this :
hr = m_pVB->Unlock();