Before we issue drawing commands to the graphics device we need to set the pipeline state needed for drawing.
Creating an Input Layout
To be able to send our vertex data to an effect we need to create an input layout object to map vertex data into shader inputs.
{
...
EffectHandle effectHandle;
VertexFormat vertexFormat;
auto buffers = device->getBuffers();
auto inputLayoutHandle = buffers->loadInputLayout(&vertexFormat, 1, effectHandle);
...
}
Setting up the graphics device context
struct Vector4;
struct Matrix4;
{
...
EffectHandle effectHandle;
VertexBufferHandle vertexBufferHandle;
InputLayoutHandle inputLayoutHandle;
Matrix4 projectionMatrix = createProjectionMatrix();
auto context = device->getImmediateContext();
context->setRenderTarget(NoHandle, NoHandle);
Vector4 clearColor(0.25f, 0.25f, 0.25f, 1);
context->clearRenderTarget(&clearColor));
context->clearDepth();
context->setEffect(effectHandle);
context->setMatrixVariable("projectionMatrix", &projectionMatrix);
context->setVertexBuffers(&vertexBufferHandle, 1);
context->setInputLayout(inputLayoutHandle);
...
}