I'm programming a wrapper for first time and working with lots of different header files, but reached a problem. I can't convert D3DMATRIX to XMMATRIX. Looking at https://learn.microsoft.com/en-us/windows/win32/dxmath/pg-xnamath-migration-d3dx it says how XMMATRIX needs to be 16bit aligned but D3DMATRIX doesn't have that requirement.
code:
XMMATRIX WVP1;
---
---
HRESULT m_IDirect3DDevice9Ex::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix)
{
WVP1 = WVP1 * *pMatrix;
---
---
}
In this code, everytime SetTransform is called I want to times the matrix thats passed through with an existing matrix.
The calling function always passes through a D3DMATRIX I think so I cant change that. I also need to work with XMMATRIX type.
I've tried some code to sort this but it hasn't helped for example
const_cast<XMMATRIX*>(&WVP1) = const_cast<XMMATRIX*>(&WVP1) * reinterpret_cast<CONST XMMATRIX*>(pMatrix);
I don't know how to go about fixing this problem.
Thanks
You should use
XMFLOAT4X4
which is the 'memory type' for a 4x4 float matrix and it has no alignment requirement. It has the same structure layout asD3DMATRIX
.