#### Archived

This topic is now archived and is closed to further replies.

# So D3DPT_LINELIST and draw command works like this?

## Recommended Posts

im drawing lines with drawPrimitive, im just curious if this is the right way to do it, im pretty sure from testing, but not confident that its right. Ive put comments in for the questions
Vertex3a vertex[3];
vertex[0].position = D3DXVECTOR3(0,0,0);
vertex[0].normal  = D3DXVECTOR3(-1,-1,-1);
vertex[0].ctexture  = D3DXVECTOR2(0,0);

vertex[1].position = D3DXVECTOR3(10,0,0);
vertex[1].normal  = D3DXVECTOR3(-1,-1,-1);
vertex[1].ctexture  = D3DXVECTOR2(0,0);

vertex[2].position = D3DXVECTOR3(0,10,0);
vertex[2].normal  = D3DXVECTOR3(-1,-1,-1);
vertex[2].ctexture  = D3DXVECTOR2(0,0);

//draws line between line 0 and 1?

lp_Device->DrawPrimitive( D3DPT_LINELIST, 0, 1);

//draws line between line 1 and 2?

lp_Device->DrawPrimitive( D3DPT_LINELIST,1, 2);

//draws line between line 0,1 and 2?

lp_Device->DrawPrimitive( D3DPT_LINELIST, 0, 2);


thanks,

##### Share on other sites
With a linelist you would need to specify 4 points, a,b,b,c if you want to draw a line between a and b and b and c. If you specify 3 points you can do it, by using D3DPT_LINESTRIP which, if you specify points a,b,c,d,e,f would draw a-b, b-c, c-d, d-e, e-f. If you specified D3DPT_LINELIST it would draw a-b, c-d, e-f.

##### Share on other sites
The second parameter to DrawPrimitive is the StartVertex, the third is the PrimitiveCount.

lp_Device->DrawPrimitive( D3DPT_LINELIST, 0, 1);
- Draw 1 line starting with vertex 0

lp_Device->DrawPrimitive( D3DPT_LINELIST,1, 2);
- Draw 2 lines starting at vertex 1 (which won''t work since there isn''t enough data in the VB)

lp_Device->DrawPrimitive( D3DPT_LINELIST, 0, 2);
- Draw 2 lines starting at vertex 0

Stay Casual,

Ken
Drunken Hyena

##### Share on other sites
You can use indices and linelists to create several unconnected lines without extra vertices.

• ### Forum Statistics

• Total Topics
628327
• Total Posts
2982091

• 22
• 9
• 9
• 13
• 11