Jump to content
  • Advertisement
Sign in to follow this  
Jonno

Drawing Lines. 2 Questions... no answers :-(

This topic is 5032 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 trying to use the Line.Draw() and Line.DrawTransformed() methods in DirectX 9 (in C#) to draw a grid and other widgets in a graphical editing program. Here's how I'm using it in my application: A. I have an array of Vector3's, each vector denoting a vertex in the line in local space. B. I iterate through the array, and apply Vector3.Project() to each point, passing in a World, View and Projection matrices as arguments to convert each point in array to screen co-ordinates. C. I then call Line.Draw() to render the line to the screen. My questions/problems (if anyone can help me out)... 1. Can I use Line.DrawTransformed() to achieve the same result, without having to apply the Project() mehoed manually to each vertex? If so, what Matrix should I provide DrawTransformed() as the argument? I have read that using DrawTransformed() causes line-styles to appear in perspective, whereas Draw() does not. 2. Is there a better way of handling grids etc. that I'm not aware of? Should I be using a Vertex Buffer instead? The grid will constantly be changing its coodinates as the view changes, so the object would have to be destroyed and re-built all the time. Is this an efficient use of a Vertex Buffer? 3. Every time I draw a line using Line.Draw(), it appears ON TOP of other rendered objects, even though all the lines are drawn BEFORE device.BeginScene() & all the other objects are rendered. Am I doing something wrong, or is this just how the device handles line drawing mixed with rendering? I've searched MSDN, the Internet & FAQ's, but I can't find any in-depth explanation or examples. Can anyone help me or point me in the right direction? Please?! Thanks in advance, Jonno.

Share this post


Link to post
Share on other sites
Advertisement
I have an answer for point 3.
Drawing line with Draw could be the same as to write something on screen: they go on top of everything. To avoid this you have to use real 3d lines using DrawPrimitive (or variants) with D3DPT_LINELIST/STRIP. There was in DirectX7 an example to do this (it showed a cactus you can modify, I can't remember nothing more :()

So the point 1 (if I'm right) has been solved by changing instruction ;) (I haven't yet the time to play with DirectX9 :))

About point 2 I know static Vertex Buffer are the best for performance... but you have to modify them. Dynamic Vertex Buffer are slower... but you can change them. I think you can change the grid using a vertex shader with very good performance.

Hope that helps.

PS- I cannot figure out how DirectX can be used to draw grid and other widgets in a graphical editing program. (I'd use MFC for example).

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!