Sign in to follow this  

Simple Line

This topic is 3633 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
{
D3DXVECTOR3 pos;
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->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE);
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

This topic is 3633 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this