3
\$\begingroup\$

I'm trying to figure out how to draw good looking lines using XNA on the WP7 platform. By good looking I mean something not skinny and flat that a simple primitive gives you. A nice gradient, or texture or something applied.

It would be pretty easy if the lines were all straight, but I need to be able to make 45* and 90* turns.

Has anyone else tried doing this? I have found ways to do it, but they all require custom shaders which the platform doesn't support. Like this one for example

Example output from that library: enter image description here

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

What the vertex shader for the round-line library that you linked does is simply take your two positions and use those to transform a pre-calculated outline of a line (including appropriate stretching).

You could do simply do the same transformations on the CPU, using DrawUserPrimitives or a DynamicVertexBuffer to draw them via BasicEffect.

You could then also calculate appropriate texture-coordinates on the CPU, to apply a texture of your choice (or use vertex colours for a gradient, and so on).

For a small number of lines, this should be perfectly acceptable, performance-wise.

\$\endgroup\$

You must log in to answer this question.