Jump to content
  • Advertisement
Sign in to follow this  

Simple Line

This topic is 3936 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. i want to draw a line between these points with color red. i want the simplest code for this, can´t find any simple code for just this purpose. A.X = 10; A.Y = 0; A.Z = -35; B.X = 10; B.Y = 0; B.Z = -5; tnx.

Share this post

Link to post
Share on other sites
Off the top of my head, and not tested or even compiled:

struct LineVertex
D3DCOLOR colour;

LineVertex verts[2];
verts[0].pos = D3DXVECTOR3(10, 0, -35);
verts[0].colour = D3DCOLOR_XRGB(255, 0, 0);
verts[1].pos = D3DXVECTOR3(10, 0, -5);
verts[1].colour = D3DCOLOR_XRGB(255, 0, 0);

// At render time:
pDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, verts, sizeof(verts[0]));

That's assuming you're drawing in 3D, a 1px line (Or whatever the default line size is), D3D9, C++, and that performance isn't much of a concern. If it is, you should create a vertex buffer, and fill it with the vertex data.

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!