   Using custom matrix.
  I've been writing a custom math library, just to brush up on my math and whatnot, but when I try to cast my new matrix type to a D3DMATRIX or D3DXMATRIX, it says there is no user defined conversion available.  The custom matrix consists of 12 float values, so I can't see why the cast doesn't work.I'm using Visual Studio Pro 2010, C++, and native DirectX 9.   
  Just because the structs have the same members, doesn't make them the same. You'll need to do something like:Matrix myMatrix;myMatrix.SetToIdentity();pDevice->SetTransform(D3DTS_WORLD, *(D3DXMATRIX*)&myMatrix);// Or:D3DXMATRIX* Matrix::ToD3DMatrix(){   return *(D3DXMATRIX*)this;}pDevice->SetTransform(D3DTS_WORLD, myMatrix.ToD3DMatrix());;  Thanks a lot, *reinterpret_cast<D3DMATRIX*> (&matrix) works fine for me.   