Question

I bought this book "Introduction to 3D Programming with DirectX 11" hoping I could port everything to C# using SharpDX, because I don't know C++. Well, I can't seem to find SharpDX's wrapper classes for XNA Math and this book deals extensively with that library. Is there something else I could get, some XNA Math C# wrapper I could download so I could keep studying?

Was it helpful?

Solution

Both MonoGame and SharpDX have math structures equivalent to the those in the original XNA Game Studio math library. For example, see Vector2 in the SharpDX namespace.

UPDATED

Note that Frank Luna's book is for C++ development. The reference to "XNAMath" here is actually to the C++ SIMD math library that shipped in the DirectX SDK. The latest version of which is DirectXMath in the Windows 8.x SDK.

In general it's pretty easy to change C++ code written for XNAMath to use DirectXMath. See MSDN for the details.

The old D3DXMath math library that shipped in D3DX9 was just replicated in D3DX10 and was never brought forward to D3DX11 at all. You can find some suggestions on moving from D3DXMath to DirectXMath here.

None of which really has anything to do with SharpDX which is a C# wrapper for Direct3D. Exactly like XNA Game Studio, SharpDX and MonoGame both contain their own C# math library because marshalling for each vector operation is exceptionally inefficient.

Note that there is a C++ wrapper for DirectXMath called SimpleMath which is included in the DirectX Tool Kit which provides "XNA Game Studio" style math types such as Vector2, Vector3, Matrix, etc. It is implemented using DirectXMath and trivially interops with DirectXMath.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top