Graphics Reference
In-Depth Information
10. Lastly, we need to assign our input layout, constant buffer, vertex and pixel shaders,
and the depth stencil state to the appropriate graphics pipeline stages.
// Tell the IA what the vertices will look like
context.InputAssembler.InputLayout = vertexLayout;
// Bind constant buffer to vertex shader stage
context.VertexShader.SetConstantBuffer(0,
worldViewProjectionBuffer);
// Set the vertex shader to run
context.VertexShader.Set(vertexShader);
// Set the pixel shader to run
context.PixelShader.Set(pixelShader);
// Set our depth stencil state
context.OutputMerger.DepthStencilState = depthStencilState;
Now that the resources have been initialized, we can implement the
D3DApplicationBase.Run method as described in the Using the
sample rendering framework recipe. Here, we will host our rendering
loop, initialize the renderers, and call their Render methods.
11. First we will initialize the instances of our renderers (the implementation of
these classes will follow shortly):
// Create and initialize the axis lines renderer
var axisLines = ToDispose(new AxisLinesRenderer());
axisLines.Initialize(this);
// Create and initialize the triangle renderer
var triangle = ToDispose(new TriangleRenderer());
triangle.Initialize(this);
// Create and initialize the quad renderer
var quad = ToDispose(new QuadRenderer());
quad.Initialize(this);
12. Next, we will prepare our world, view, and projection matrices. These matrices
are multiplied and the result is used to update the WVP constant buffer within
the render loop to perform vertex transformations within the vertex shader.
// Initialize the world matrix
var worldMatrix = Matrix.Identity;
// Set camera position slightly to the right (x), above (y)
// and behind (-z)
 
Search WWH ::




Custom Search