I decided I wanted to learn DirectX and I have been trying to get started. I got a copy of Frank Luna's DirectX 11 programming book, but I am unable to run any code.
I have had most success by using visual studio 2010 and the June 2010 DirectX SDK, but the code still wont run. I pointed VS to the SDK's include and library files, and there are no errors in the code, but when I try to build this example:
#include <windows.h> // for FLOAT definition
#include <xnamath.h>
#include <iostream>
using namespace std;
// Overload the "<<" operators so that we can use cout to
// output XMVECTOR and XMMATRIX objects.
ostream& operator<<(ostream& os, FXMVECTOR v)
{
XMFLOAT4 dest;
XMStoreFloat4(&dest, v);
os << "(" << dest.x << ", " << dest.y << ", " << dest.z << ", " << dest.w << ")";
return os;
}
ostream& operator<<(ostream& os, CXMMATRIX m)
{
for(int i = 0; i < 4; ++i)
{
for(int j = 0; j < 4; ++j)
os << m(i, j) << "\t";
os << endl;
}
return os;
}
int main()
{
// Check support for SSE2 (Pentium4, AMD K8, and above).
if( !XMVerifyCPUSupport() )
{
cout << "xna math not supported" << endl;
return 0;
}
XMMATRIX A(1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 2.0f, 0.0f, 0.0f,
0.0f, 0.0f, 4.0f, 0.0f,
1.0f, 2.0f, 3.0f, 1.0f);
XMMATRIX B = XMMatrixIdentity();
XMMATRIX C = A * B;
XMMATRIX D = XMMatrixTranspose(A);
XMVECTOR det = XMMatrixDeterminant(A);
XMMATRIX E = XMMatrixInverse(&det, A);
XMMATRIX F = A * E;
cout << "A = " << endl << A << endl;
cout << "B = " << endl << B << endl;
cout << "C = A*B = " << endl << C << endl;
cout << "D = transpose(A) = " << endl << D << endl;
cout << "det = determinant(A) = " << det << endl << endl;
cout << "E = inverse(A) = " << endl << E << endl;
cout << "F = A*E = " << endl << F << endl;
return 0;
}
I get this one error: LINK : fatal error LNK1104: cannot open file 'd3dll.lib'
It knows where to find that file, and I looked in the folder I pointed VS to, and the file is right there, but it can't open it.
I am running Windows 7, and I realize this is an old version of the SDK, but using the current windows SDK causes even more issues for me.
I just need a little help getting code running. I am open to switching SDKs if I can get it to work.
edit: This definitely has something to do with Luna's book. d3dll.lib is supposed to be d3d11.lib... I think. Luna's book says to add these to the linker dependencies: