How to read vertices from vertex buffer in Direct3d11

前端 未结 3 872
暗喜
暗喜 2020-12-17 05:55

I have a question regarding vertex buffers. How does one read the vertices from the vertex buffer in D3D11? I want to get a particular vertex\'s position for calculations, i

3条回答
  •  Happy的楠姐
    2020-12-17 06:34

    The following code only get the address of the mapped resource, you didn't read anything before Unmap.

    vert = (VERTEX*) ms.pData;
    

    If you want to read data from the mapped resource, first allocate enough memory, then use memcpy to copy the data, I don't know your VERTEX structure, so I suppose vert is void*, you can convert it yourself

    vert = new BYTE[ms.DepthPitch];
    memcpy(vert, ms.pData, ms.DepthPitch];
    

提交回复
热议问题