3D Maths - DirectX Math



The initialization process of Direct3D requires some specific Direct3D types and basic graphics concepts. This chapter addresses these requirements.

Direct3D includes a design of low-level graphics API (Application Programming Interface) that enables us to render 3D worlds using 3D hardware acceleration. The most important thing is that Direct3D provides the software interfaces through which a user can use the graphics hardware. The best illustration is to instruct the graphics hardware to clear the render target.

Now, let us focus on DirectXMath which is the primary focus of this chapter. DirectXMath is written with the help of standard Intel-style intrinsics, which is usually portable to all compilers. The ARM code paths use ARM-style intrinsics which is considered to be portable.

The DirectXMath library makes use of two commonly implemented extensions to Standard C++ which are mentioned below −

  • Anonymous structs, which are widely supported and are part of the C11 standard.

  • Anonymous unions, but these are part of the C++ and C99 standard.

DirectXMath is an inline SIMD which includes all the linear algebra library features for use in games and graphics apps.

The DirectXMath library includes inline features and uses only the concerned Visual C++ intrinsics. Hence, it is considered to be more compatible with all versions of Windows supported by Visual C++. There's no standard configuration which will put DirectXMath in the include path but a user can add it manually or make use of the NuGet package which is designed for that unique purpose. Keep in mind there are many differences which are completed with DirectX development for Windows XP support.

Migrating code

The details on moving from XNAMath to DirectXMath are covered in Code Migration from the XNA Math Library.

Make sure as a user you read all the details on the calling convention types which are designed to deal with the various architectures and vector calling conventions.

If a user is writing client code that is intended to build with both DirectXMath 3.06+ (Windows 8.1 SDK / VS 2013) and DirectXMath 3.03 (Windows 8 XDK / VS 2012), the following adapter code can be used −

#include <DirectXMath.h>
namespace DirectX {
   #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV)
   #define XM_CALLCONV __fastcall
   typedef const XMVECTOR& HXMVECTOR;
   typedef const XMMATRIX& FXMMATRIX;
   #endif
}

DirectXMath includes all the written intrinsic standards, which should be portable to other compilers. The ARM codepaths also include ARM-style intrinsics which should be considered portable.

Advertisements