How to use D3DXLine

Started by
8 comments, last by johan_swe 20 years, 5 months ago
I want to use D3DXLine for lines in 3D-space. How?
Advertisement
Look here.
It doesn't work.

The code:

D3DXMATRIX matWorld;
D3DXMatrixIdentity(&matWorld);

D3DXVECTOR3 Lines[2] = { m_Start, m_End };

m_pD3DXLine->DrawTransform(Lines, 2, &matWorld, m_Color);

It seems to draw the line in screen space.

[edited by - johan_swe on November 12, 2003 1:19:44 PM]
If you want perspective-correct lines, you have to pass your projection matrix, not an identity matrix. Query the device for the projection matrix and pass that to the function.
Ït still doesn''t work...

D3DXMATRIX matProjection;

pDevice->GetTransform(D3DTS_PROJECTION, &matProjection);

D3DXVECTOR3 Lines[2] = { m_Start, m_End };

m_pD3DXLine->DrawTransform(Lines, 2, &matProjection, m_Color);
Have you set up a projection matrix using a D3DXMatrixPerspective*() function followed by a SetTransform() call? If you haven''t set a projection matrix, then querying for one won''t do any good.
Yep.
Did you check for GetTransform result?
GetTransform does not work on pure devices.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Yes, I did. I don''t know what a pure device is so I don''t think I''m using one.
When you enumerate devices you can check their caps.
Especially when you use the D3D Framework from the samples you will likely choose the pure device.

But you already said, you checked and it succeeds, so that isn''t your problem.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement