Microsoft DirectX 8.0 (C++) |
Microsoft® DirectX® 8.0 supports two types of higher order primitives, or patches. These are referred to as N-Patches and Rect/Tri patches. N-Patches can be rendered using any triangle rendering call by enabling D3DRS_PATCHSEGMENTS to a value greater than 1.0. Rect/Tri patches must be rendered using the following explicit entry points.
You can use the following methods to draw patches in Microsoft Direct3D® for DirectX.
DrawRectPatch draws a rectangular high-order patch specified by the pRectPatchInfo parameter using the currently set streams. The Handle parameter is used to associate the patch with a handle, so that the next time the patch is drawn, there is no need to respecify pRectPatchInfo. This makes it possible to precompute and cache forward difference coefficients or other information, which in turn enables subsequent calls to DrawRectPatch using the same handle to execute efficiently.
It is intended that for static patches, an application would set the vertex shader and appropriate streams, supply patch information in the pRectPatchInfo parameter, and specify a handle so that Direct3D can capture and cache information. The application can then call DrawRectPatch subsequently with pRectPatchInfo set to NULL to efficiently draw the patch. When drawing a cached patch, the currently set streams are ignored. However, it is possible to override the cached pNumSegs by specifying new values for pNumSegs. Also, it is required to set the same vertex shader when rendering a cached patch as was set when it was captured.
For dynamic patches, the patch data changes for every rendering of the patch, so it is not efficient to cache information. The application can convey this to Direct3D by setting Handle to 0. In this case, Direct3D draws the patch using the currently set streams and the pNumSegs values and does not cache any information. It is not valid to simultaneously set Handle to 0 and pPatch to NULL.
By respecifying pRectPatchInfo for the same handle, the application can overwrite the previously cached information.
If pNumSegs is set to NULL, then the tessellator uses D3DRS_PATCHSEGMENTS to control the amount of tessellation. In this case, obviously, the same tessellation is used for all sides. There are no special methods for N-patches. Tessellation is simply controlled by D3DRS_PATCHSEGMENTS. It is necessary to supply normals.
DrawTriPatch is similar to DrawRectPatch except that it draws a triangular high-order patch.