1
// 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;
4

1 回答 1

2

顶点缓冲区存储为字节,您需要创建一个描述这些字节的输入布局。

您的代码中应该有类似的内容。

// Define the input layout
D3D10_INPUT_ELEMENT_DESC layout[] =
{
    { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
UINT numElements = sizeof( layout ) / sizeof( layout[0] );

// Create the input layout
D3D10_PASS_DESC PassDesc;
g_pTechnique->GetPassByIndex( 0 )->GetDesc( &PassDesc );
hr = g_pd3dDevice->CreateInputLayout( layout, numElements, PassDesc.pIAInputSignature,
                                      PassDesc.IAInputSignatureSize, &g_pVertexLayout );

在此示例中layout,描述结构的是 。

于 2013-11-09T03:17:11.533 回答