1. Should I?
Should I do this at all and / or is this the best way to do this?
Generally speaking, you use the Windows SDK to write new code, but you do not need to convert any old code (yours, or especially others). It is just a waste of time. You can install the DirectX SDK to be able to create it.
On the other hand, this is a good opportunity to learn a little more about DrectX and its infrastructure. For example, porting from D3DXMath to DirectXMath (formerly XMMath), you will learn about the pros and cons of SSE-based math libraries, and this is a good place to start writing your own.
2. How?
If you really decide to do this hard work, then 90% of the information you will find in a good article by Chuck Walborn - MSFT: Life without D3DX . Another 9.9% you yourself will learn from the documentation and 0.1% more from searching for the source code of DirectXMath (this is a library of headers, all functions and you cannot study them freely). You are probably also interested in other articles on this guy on MSDN.
3. operator+ problem
Instead of the single type D3DXVECTORn (where n is the number of components), the new math contains two types: XMFLOATn and XMVECTOR . The same goes for matrices: XMMATRIX and XMFLOATaXb (where a and b are matrix sizes).
XMFLOAT people should just store values. It just floats. No operators are defined for them and there are no functions except XMLoad* / XMStore* to accept them.XMVECTOR and XMMATRIX are workhorses: they are used in all functions and also have overloaded operators (which are not recommended for use. Use XM* functions instead). They use internal SSE supersonic speeds. But ... it's hard to use to store values. For example, you will have alignment problems if you make a member of the XMVECTOR class.- So basically, you save and move your values ββto
XMFLOAT s, but before any calculations, you convert them to XMVECTOR and XMMATRIX using XMLoad* functions (as you did with XMVector3TransformCoord() ), and after the calculations you convert them back to XMFLOAT s using the XMStore* functions. Or you can make a little more profit by combining your class es and struct s correctly, so you can directly store XMVECTOR and XMMATRIX (you might need a aligned memory allocator).
OK, now you are ready to go. Happy porting! =)
Drop source share