D3DX is a utility library that provides helper services. It is a layer above the Direct3D component.
D3DX supports single-pixel-wide antialiased lines. Line patterns are no longer supported.
The line drawing library emulates lines using texture triangles and assumes the following:
For antialiased line rendering in multisample render targets, use ID3DXLine which generates textured polygons. The pixel coverage values, generated by antialiased line rasterization, modulate the pixel's alpha value computed by the pixel shader. To draw an antialiased line, an application must enable alpha blending and then it must set the D3DRS_ANTIALIASEDLINEENABLE render state to TRUE.
The library supports drawing colored line strips with the following line features, each of which is independent of any other:
Note No mitering is supported.
The library uses native hardware line drawing support (if available in the device) only if:
Single-pixel-wide antialiased lines are supported by some hardware, so the library uses that, if available. The LineCaps member of the D3DCAPS9 structure enumerates hardware capabilities for line-drawing primitives.
When the software line drawing is used, each line is expanded into a rectangle and four vertices are sent down to the driver.
Each line segment is drawn with two triangles. The width of the primitive is the specified width plus 1.0, which may result in an extra row or column of pixels. As the line gets wider, the antialias gradient in the texture becomes more coarse, and more fully-opaque texels are replicated around the middle. The gradient is encoded in the v-direction of the texture, and typically replicated along the u-direction. The texture addressing mode for v is clamp.
Each line segment in the list can be considered to be a separate line that happens to start from the previous end point.
Antialiasing quality along the edges parallel to the length of the original line suffers as the line gets wider. It is expected that line widths greater than 32.0 will start to exhibit artifacts along these edges.