Dashed line (a la GL_LINE_STIPPLE)

Started by
1 comment, last by desertcube 17 years, 10 months ago
Hi all, I'm currently learning directX in c# after coming from an openGL C++ background. My codes running fine, mainly using 2D routines, however I need to draw a dashed line! Sounds simple right? At the moment I have a vertex array with DrawUserPrimitives(PrimitiveType.LineList), however, I need to draw an outline with dashed lines. I can't seem to find anything; the Line class seems helpful however I've been unable to get it to work with the current view matrix. One solution I've thought of is to draw the outlines first (before any drawing is on screen) then use a pixel shader to make them dashed. This seems overly complex, surely there's another way? I have a feeling it's something to do witht he render state, but have been unable to find anything related. Can any one shed some light for me?
Advertisement
The Pattern property of the Line class should do what you need.


What problems are you having with the view transform when using lines?

AFAIK (I'm not so expert with managed DX...), if you're trying to draw lines in 3D space, the matrix you pass to Line.DrawTransform needs to be the concatenation of the world, view and projection matrices - i.e. one matrix to transform your 3D points from world space into screen space.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Quote:Original post by S1CA
AFAIK (I'm not so expert with managed DX...), if you're trying to draw lines in 3D space, the matrix you pass to Line.DrawTransform needs to be the concatenation of the world, view and projection matrices - i.e. one matrix to transform your 3D points from world space into screen space.


I was only supplying the world matrix! Thanks for your help, works flawlessly now.

This topic is closed to new replies.

Advertisement