I am developing a DirectX 11 game in C++ and I am trying to create a view matrix but when I do I am getting the following debug error:
Assertion failed!
Program: ...ate-Direct3D11\Build\Debug\Template-Direct3D11.exe
File: C:\Program Files (x86)\Windows Kits...\DirectX...rix.inl
Line: 1971
Expression: !XMVector3Equal(EyeDirection, XMVectorZero())
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts
(Press Retry to debug the application - JIT must be enabled)'Template-Direct3D11.exe' (Win32): Loaded 'C:\Windows\SysWOW64\TextShaping.dll'.
Template-Direct3D11.exe has triggered a breakpoint.
Here is the code:
DirectX::XMVECTOR eyePos = DirectX::XMVectorSet(0.f, 0.f, -2.f, 0.f);
DirectX::XMVECTOR lookAtPos = DirectX::XMVectorSet(0.f, 0.f, -2.f, 0.f);
DirectX::XMVECTOR upVector = DirectX::XMVectorSet(0.f, 1.f, 0.f, 0.f);
DirectX::XMMATRIX view = DirectX::XMMatrixLookAtLH(eyePos, lookAtPos, upVector); //Debug Error
I cannot find any information online about this because it seems that everyone has a different error than me.
Can anyone help?
The eyPos
and the lookAtPos
you are setting are the same value... The result is a 0-length unit vector for direction.
DirectX::XMVectorSet
is not the best way to initialize a constant vector. Read the DirectXMath Programmer's Guide particularly the Getting Started guide.