Search code examples
directxhlsl

How to draw 1 pixel long dotted lines in DirectX?


How can I draw lines similar to the negative axis in Google Sketchup ? I know I can parametrize the line using texture coordinates and draw the line in homogenous coordinates. But if my pixel shader has some logic like tex.u%5<1, surely sometimes I'll get 2 pixel dashes or 0 pixel dashes. How exactly would I get exactly 1 pixel dashes every say 5 pixels like in the screenshot ?

Thanks!

enter image description here


Solution

  • Styled and pattern lines are best drawn using Direct2D. With DirectX 11.1 or later, interop is quite easy.

    See MSDN