So, I started programming in DirectX11 today, I’ve had a lot experience with coding, but not specifically DirectX, so I went and look at some tutorials. All was going swell, I could initialize a window, set a background color, but then as soon as I tried to define a shader and draw an object, it just crashes on load. This code is extremely simple, and I’ve put it in a rar so you can tell me what’s wrong. I’m coding in Visual C++ Express Edition because I tried for hours yesterday to get OpenGL reference paths set up in Netbeans to no avail, so I’m not trying to get DirectX working there either yet. Here’s the code I have currently: http://www.mediafire.com/?i8w1trkx7c03qts
I also tried downloading and just running the provided exe in http://www.dx11.org.uk/3dcube.htm, to test if it’s my direct X or something, and that one gives me an error of “Failed to create D3D11 device”, which from their code is a failure to complete the “D3D11CreateDeviceAndSwapChain” command. So honestly, what am I doing wrong/what is happening? (And any help on how to set the directX library references up in netbeans would be a great help).
It works for me 🙂
I had to remove L prefix of some strings for compiling code:
"shaders.hlsl","WindowClass","Our First Direct3D Program"Do you have .hlsl file in the same path than your executable?
Also you can’t start the program from VS. You will need to launch the .exe from
the explorer.
But you can set an absolute path to your shader if you don’t want this behavior, like that:
Edit:
Also when creating a device or device/swapchain always use
D3D11_CREATE_DEVICE_DEBUGin debug mode. This will print in VS Output Window helpful warnings and errors (everything looks OK on my side).
Edit2:
Also always check for error codes everywhere application can fail: