Great!
The transformation issue is now resolved, now I'm trying to draw all the lines with only a single draw call, so I tried changing the following code:
// The following code draw line per draw call (I don't want that)
TVertex vrts[4];
vrts[0].pos = v0; vrts[0].otherPos = v1;
vrts[1].pos = v1; vrts[1].otherPos = v0;
vrts[2].pos = v0; vrts[2].otherPos = v1;
vrts[3].pos = v1; vrts[3].otherPos = v0;
vrts[0].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[1].thickness = D3DXVECTOR3( g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[2].thickness = D3DXVECTOR3( g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[3].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[0].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[1].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[2].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[3].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );
d3ddev->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, vrts, sizeof( TVertex ) );
To:
// In this code, I'm trying to draw multiple lines with one single draw call
TVertex vrts[8]; // 8 instead of 4 (8 = 2 lines)
// Line 1
D3DXVECTOR3 v0(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 v1(0.0f, 100.0f, 0.0f);
vrts[0].pos = v0; vrts[0].otherPos = v1;
vrts[1].pos = v1; vrts[1].otherPos = v0;
vrts[2].pos = v0; vrts[2].otherPos = v1;
vrts[3].pos = v1; vrts[3].otherPos = v0;
vrts[0].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[1].thickness = D3DXVECTOR3( g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[2].thickness = D3DXVECTOR3( g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[3].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[0].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[1].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[2].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[3].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );
// Line 2
D3DXVECTOR3 pV0(200.0f, 0.0f, 0.0f);
D3DXVECTOR3 pV1(200.0f, 100.0f, 0.0f);
vrts[4].pos = pV0; vrts[4].otherPos = pV1;
vrts[5].pos = pV1; vrts[5].otherPos = pV0;
vrts[6].pos = pV0; vrts[6].otherPos = pV1;
vrts[7].pos = pV1; vrts[7].otherPos = pV0;
vrts[4].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[5].thickness = D3DXVECTOR3( g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[6].thickness = D3DXVECTOR3( g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[7].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[4].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[5].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[6].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[7].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );
// Draw all lines
d3ddev->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 4, vrts, sizeof( TVertex ) );
Now, the two lines are connected with each others, which of course undesired since I want to draw multiple separate lines with one draw call.
Do I have to set index buffer to draw multiple lines with one draw call? If yes, how do I fill the index buffer?