I'm working on a Directx C++/CX (Universal Windows) project.
I'm not all that familiar with Directx11 by the way.
My code is mostly based on the sample projects on MSDN related to rendering directx in UWP using swapchainpanels.
Now I wanted to add a float variable to the shader. I believe this has to be done using the constantbuffer. Currently this is as follows (and works):
//c++:
struct ModelViewProjectionConstantBuffer
{
DirectX::XMFLOAT4X4 model;
DirectX::XMFLOAT4X4 view;
DirectX::XMFLOAT4X4 projection;
//float distance;
};
//hlsl:
cbuffer ModelViewProjectionConstantBuffer : register(b0)
{
matrix model;
matrix view;
matrix projection;
//float distance;
};
Now when I add a float, it stops working. It throws an exception when I update the constant buffer (which happens before each rendered frame):
_d3dContext->UpdateSubresource(
_constantBuffer.Get(),
0,
NULL,
&_constantBufferData,
0,
0
);
The exception is a SEHException (so as far as I can find, this doesn't tell me anything).
I'm basing all this on the following page: https://msdn.microsoft.com/en-us/library/ff476896(v=vs.85).aspx
Can anyone tell me what I'm doing wrong?