Graphics Reference
In-Depth Information
9. We can load the control points from a file, such as for the famous Utah Teapot (refer
to the link in the See also section). The following diagram shows how the vertices
match the control points of a cubic Bezier surface:
Cubic Bezier surface control point layout
10. Finally, within the DoRender override, we will draw the surface with the
following code:
// Tell the IA we are using a list of patches with 16
// control points each
context.InputAssembler.PrimitiveTopology =
PrimitiveTopology.PatchListWith16ControlPoints;
// Pass in the vertices
context.InputAssembler.SetVertexBuffers(0, vertexBinding);
context.Draw(16, 0);
The completed sample within the downloaded content includes the options
to enable a second and third draw sequence for the Bezier patch that
outputs the control points as PointList and LineList . This can be
helpful to visualize how the control points impact the final result.
11. Within the D3DApp.CreateDeviceDependentResources method, compile the
shader methods as per the triangle and quad shader code from the previous recipe.
12. Lastly, render the Bezier surface, as shown in the previous recipe. Remember to reset
the vertex, hull, and domain shaders afterwards.
 
Search WWH ::




Custom Search