So I was messing around with some text handling to go with DirectXTK's text rendering and I think I might have "pissed off" visual studio. After getting some errors because I tried to make it work with arrays out of bounds it gave me errors, and I don't know if I simply got the error too many times or if I by mistake tried to continue running the program beyond the error but now I get an error (the same I think) in a completly different class.
HRESULT hr;
wchar_t VSFilepath[250] = L"";
wchar_t PSFilepath[250] = L"";
wchar_t SVSFilepath[250] = L"";
wchar_t SPSFilepath[250] = L"";
wcscat_s(VSFilepath, directory);
wcscat_s(VSFilepath, L"\\Shaders\\Player\\PlayerVertexShader.hlsl");
wcscat_s(PSFilepath, directory);
wcscat_s(PSFilepath, L"\\Shaders\\Player\\PlayerPixelShader.hlsl");
//create vertex shader
ID3DBlob* pVS = nullptr;
hr = D3DCompileFromFile(VSFilepath,
nullptr,
D3D_COMPILE_STANDARD_FILE_INCLUDE,
"VS_main",
"vs_5_0",
0,
NULL,
&pVS,
nullptr);
hr = gDevice->CreateVertexShader(pVS->GetBufferPointer(),
pVS->GetBufferSize(),
nullptr,
&playerVertexShader);
//create input layout (verified using vertex shader)
D3D11_INPUT_ELEMENT_DESC inputDesc[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
};
hr = gDevice->CreateInputLayout(inputDesc,
ARRAYSIZE(inputDesc),
pVS->GetBufferPointer(),
pVS->GetBufferSize(),
&playerVertexLayout);
pVS->Release();
//create pixel shader
ID3DBlob* pPS = nullptr;
hr = D3DCompileFromFile(PSFilepath,
nullptr,
D3D_COMPILE_STANDARD_FILE_INCLUDE,
"PS_main",
"ps_5_0",
0,
NULL,
&pPS,
nullptr);
hr = gDevice->CreatePixelShader(pPS->GetBufferPointer(),
pPS->GetBufferSize(),
nullptr,
&playerPixelShader);
pPS->Release();
By stepping through the program I have come to the following conclusion:
After I use a create shader function, CreateVertexShader for example, the next time I try to use D3DCompileFromFile the program stops and with "First-chance exception at 0x772BDBB7 in game.exe: 0xC0000008: An invalid handle was specified."
It doesn't matter if I try to comment out the CreateVertexShader, sure it can create the next pixelshader but the next D3DCompileFromFile gives me the same error, and all hr results are S_OK.
The thing is that his code has worked probably a hundred times before this and I haven't changed anything related to it, so I am extremely confused as to what has happened.