This section of the archives stores flipcode's complete Developer Toolbox collection,
featuring a variety of mini-articles and source code contributions from our readers.

Textured Lines In D3D
Submitted by

Here's a way to solve a recurrent problem : emulating glLineWidth in Direct3D.
Better : you can use this code to draw textured lines, which are often needed to
create a lot of special effects (lightning bolts, toon-like silhouettes, etc).
The code computes a world quad from a segment in world space. Simply render the
quad instead of the segment! If you have a line-strip, compute one quad for each
segment, then render everything as a single non-indexed tristrip of 4 *
NbSegments vertices.
You should be able to use it with any flexible vertex format (FVF).
All matrices are 4x4 D3D-compliant matrices. mRenderWidth is the width of the
render window (ex: 640)
I hope it will be useful to some of you. I know I would have loved to have this
right from the start (read: included in D3D...). By the way, it's not supposed
to be optimized so don't bother telling me it's not :)

Here's a way to solve a recurrent problem : emulating glLineWidth in Direct3D. Better : you can use this code to draw textured lines, which are often needed to create a lot of special effects (lightning bolts, toon-like silhouettes, etc).
The code computes a world quad from a segment in world space. Simply render the quad instead of the segment! If you have a line-strip, compute one quad for each segment, then render everything as a single non-indexed tristrip of 4 * NbSegments vertices.
You should be able to use it with any flexible vertex format (FVF).
Here's the main routine :