// Lock the vertex buffer.
hr = aVertexBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&verticesPtr);
// Copy the data into the vertex buffer.
memcpy(verticesPtr, (void*)vertices, (sizeof(LolAnyDataStructure)* aVertexCount));
在这种情况下,我使用的是结构 LolAnyDataStructure,当您调用 IASetVertexBuffers 时,DX 将如何知道结构中的纹理和位置在哪里。
编辑:
vertexBufferDesc.Usage = D3D10_USAGE_DYNAMIC;
vertexBufferDesc.ByteWidth = sizeof(VertexType)* aVertexCount;
vertexBufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
vertexBufferDesc.MiscFlags = 0;