Skip to main content
GameDev.net gamedev.net
🔒 Locked

Dashed line (a la GL_LINE_STIPPLE)

Started by desertcube Jun 13, 2006 at 4:35 PM 1 replies 4.1k views
Original Post
desertcube
desertcube
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?
S1CA
S1CA
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
desertcube
desertcube
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.