Jump to content
  • Advertisement
Sign in to follow this  
desertcube

OpenGL Dashed line (a la GL_LINE_STIPPLE)

This topic is 4511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!