home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 1 Vector Algebra / XMVECTOR / InitFunctions.cpp next >
Encoding:
C/C++ Source or Header  |  2016-03-02  |  1.1 KB  |  46 lines

  1. /*
  2. #include <windows.h> // for XMVerifyCPUSupport
  3. #include <DirectXMath.h>
  4. #include <DirectXPackedVector.h>
  5. #include <iostream>
  6. using namespace std;
  7. using namespace DirectX;
  8. using namespace DirectX::PackedVector;
  9.  
  10. // Overload the  "<<" operators so that we can use cout to 
  11. // output XMVECTOR objects.
  12. ostream& XM_CALLCONV operator<<(ostream& os, FXMVECTOR v)
  13. {
  14.     XMFLOAT3 dest;
  15.     XMStoreFloat3(&dest, v);
  16.  
  17.     os << "(" << dest.x << ", " << dest.y << ", " << dest.z << ")";
  18.     return os;
  19. }
  20.  
  21. int main()
  22. {
  23.     cout.setf(ios_base::boolalpha);
  24.  
  25.     // Check support for SSE2 (Pentium4, AMD K8, and above).
  26.     if (!XMVerifyCPUSupport())
  27.     {
  28.         cout << "directx math not supported" << endl;
  29.         return 0;
  30.     }
  31.     
  32.     XMVECTOR p = XMVectorZero();
  33.     XMVECTOR q = XMVectorSplatOne();
  34.     XMVECTOR u = XMVectorSet(1.0f, 2.0f, 3.0f, 0.0f);
  35.     XMVECTOR v = XMVectorReplicate(-2.0f);
  36.     XMVECTOR w = XMVectorSplatZ(u);
  37.  
  38.     cout << "p = " << p << endl;
  39.     cout << "q = " << q << endl;
  40.     cout << "u = " << u << endl;
  41.     cout << "v = " << v << endl;
  42.     cout << "w = " << w << endl;
  43.     
  44.     return 0;
  45. }
  46. */