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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
void InputAssemblerStage()
{
D3D11_INPUT_ELEMENT_DESC Layouts[2] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA , 0}
};
Vertex VerticesData[] =
{
D3DXVECTOR3(0.1f, 0.2f, 0.3f),
D3DXCOLOR(0.2f, 0.2f, 0.2f, 0.0f),
D3DXVECTOR3(0.1f, 0.1f, -0.5f),
D3DXCOLOR(0.1f, 0.2f, 0.3f, 0.1f)
};
D3D11_BUFFER_DESC VertexBufferDesc;
VertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
VertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
VertexBufferDesc.CPUAccessFlags = 0;
VertexBufferDesc.MiscFlags = 0;
VertexBufferDesc.ByteWidth = sizeof(Vertex);
D3D11_SUBRESOURCE_DATA VertexData;
VertexData.pSysMem = VerticesData;
VertexData.SysMemPitch = 0;
VertexData.SysMemSlicePitch = 0;
/* Creating the input layout */
device->CreateInputLayout(Layouts, 2, NULL, NULL, &inputLayout);
/* Creating the vertex buffer */
device->CreateBuffer(&VertexBufferDesc, &VertexData, &VertexBuffer);
UINT stride = sizeof(Vertex);
UINT offset = 0;
DevContext->IASetVertexBuffers(0, 1, &VertexBuffer, &stride, &offset);
DevContext->IASetInputLayout(inputLayout);
DevContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
DevContext->Draw(2, 0);
}
| |