Microsoft DirectX 9.0

Direct3D Extensions (D3DX) Line Drawing

Direct3D extensions (D3DX) has been extended to support single-pixel-wide antialiased lines. Support for line patterns is removed; the D3DRS_LINEPATTERN render state is no longer supported.

The line drawing library emulates lines using texture triangles assuming:

Setting the D3DRS_ANTIALIASEDLINEENABLE render state to TRUE or FALSE enables or disables line antialiasing. The default state is FALSE.

The D3DRS_ANTIALIASEDLINEENABLE render state applies to triangles drawn in wireframe mode as well as line drawing primitive types. When rendering to a multisample render target, the D3DRS_ANTIALIASEDLINEENABLE render state is ignored and all lines are rendered aliased.

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. An application must enable alpha blending to draw the antialiased line.

The changes include:

// New render state
// Can be TRUE (nonzero) or FALSE (zero)

// New capability bit

// Deleted the following 

Functionality Description

The library supports drawing colored line strips with the following line features, each of which is independent of the 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.

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 1.0 + the specified width, which may result in an extra row or column of pixels. As the line gets wider, the antialias gradient in the texture becomes coarser, 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.

© 2002 Microsoft Corporation. All rights reserved.