Hmmm, now I realize that there's even more to it, since you dont initialize your pointers to anything. Always do that IMO:
ID3D10Blob *vBlob = NULL;
Or
nullptr if you're in for modern C++.
Anyway, if not it could be anything. In debug mode they get initialized to the magic number 0xCCCCCCCC (
see here).
Checking for NULL
should work with
if(vBlob == NULL)
or even (
Edit: corrected)
if(!vBlob)
Why does it not work for you ?
Sooo, the why is it NULL (because I think it is) ? If the shader compilation fails, it will be set so (Note: I don't use VS 2012 but 2010, but I can reproduce that with the old D3DX function here).
Checking for the compilation works something like this (careful, I can't really check this, I just transliterated it for you):
ID3D10Blob *vBlob = NULL;
ID3D10Blob *errors = NULL;
HRESULT hr;
hr = D3DCompileFromFile(L"Shaders.hlsl",NULL,NULL,"VShader","vs_5_0",0,0,&vBlob,&errors);
if(FAILED(hr))
{
if(errors)
{
MessageBoxA(0, (LPCSTR)errors->GetBufferPointer(), "Error", 0);
errors->Release();
}
else
{
MessageBoxA(0, "Compilation failed. Is the file where it should be ?", "Error", 0);
}
exit (EXIT_FAILURE);
}
If that code does not work, maybe someone else is so kind to correct it (
Edit:Found already a typo, vBlob, not pBlob. Corrected)
So either your app cannot find your shader file, or there's an error in there.
Interactive debugging. Well, you could hit the 'Break' button when the crash occurs, you should be on the exact line where it happens. Move your mouse over the variables and be amazed (Hint: vBlob).