The July 2012 release of the Xbox 360 XDK includes a new version of XNA Math, version 2.05. We are making it available here for Windows developers. The update is subject to the same EULA as the DirectX SDK (June 2010) release MIT license.
XNA Math version 2.05 includes:
- Template forms have been added for
XM_STRICT_XMMATRIXcompilation define has been added for opaque
- Stream stride and count arguments have been changed to
- The pDeterminant parameter of
XMMatrixInverseis now optional.
- Additional operator= overloads for
XMUBYTE4types are now available.
See XNA Math version 2.04 for details on what changed previously compared to XNA Math version 2.03 in the DirectX SDK (June 2010) release.
Why update XNA Math?
The DirectXMath library that ships as part of the Windows 8.0 SDK and Visual Studio 2012 RC is the recommended latest version of “XNA Math”. You can think of it as “XNAMath version 3.x”. It is very similar although it does have a number of ‘breaking’ changes (there’s a migration guide as well), requires Visual Studio 2010 or later, and is not available for the Xbox 360.
The primary purpose for the XNA Math version 2.05 update is for developers who need to maintain compatibility with the Xbox 360 version in the XDK or VS 2008, but want to prepare for migration to DirectXMath or support compiling with either math library.
XNAMath / DirectXMath Portability Recommendations
For an example of how to use this, see DirectXTex which builds with either DirectXMath or using the
USE_XNAMATH define with XNA Math version 2.05. Here are some guidelines for achieving this:
- Set preprocessor defines
XM_STRICT_MATRIXin your build to ensure you are using
XMMATRIXas opaque types.
- Where possible, prefer the template forms to function forms. Note that for template forms, you should use simple indices (0-7) rather than the
XM_PERMUTE_?values which have different definitions in the two library versions or
XM_SWIZZLE_?which is not defined for XNA Math.
- Make use of
using namespacestatements to cope with the lack of namespaces in XNA Math
Note: DirectXMath is now hosted on GitHub.