Graphics Reference
In-Depth Information
17. For the TriangleRenderer C# class, change the DoRender method to set the
PrimitiveTopology enumeration to a patch list with three control points:
context.InputAssembler.PrimitiveTopology =
PrimitiveTopology.PatchListWith3ControlPoints;
18. For the QuadRenderer class, we do not need an index buffer. Instead, we will
use the following code in the DoRender method to set up the patch topology
and draw the vertices:
context.InputAssembler.PrimitiveTopology =
PrimitiveTopology.PatchListWith4ControlPoints;
context.InputAssembler.SetVertexBuffers(0, quadBinding);
context.Draw(4, 0);
19. Create an instance of our renderers within D3DApp.Run , and add a call to their
Render method within the render loop.
20. Add the TriangleRenderer and QuadRenderer classes to the render loop:
// TRIANGLE
context.VertexShader.Set(tessellateVertexShader);
context.HullShader.Set(activeTriTessellator);
context.DomainShader.Set(tessellateTriDomainShader);
triangle.Render();
// QUAD
context.VertexShader.Set(tessellateVertexShader);
context.HullShader.Set(activeQuadTessellator);
context.DomainShader.Set(tessellateQuadDomainShader);
quad.Render();
...
// RESET SHADERS
context.VertexShader.Set(vertexShader);
context.HullShader.Set(null);
context.DomainShader.Set(null);
Attempting to use the wrong primitive topology type with the hull/domain
shader may result in an unexpected behavior; therefore, we clear the
shaders to ensure that they don't interfere with other renderers.
For example, on a test machine, it was possible to crash the display driver
subsystem by specifying a standard triangle list while a hull shader was set.
 
Search WWH ::




Custom Search