Hi,
Recently I've been having some issues while working with DirectX and I'm curious about some error handling.
hr = D3DX11CompileFromFile("Effects.fx", 0, 0, "VS", "vs_4_0", 0, 0, 0, &VS_Buffer, 0, 0);
hr = D3DX11CompileFromFile("Effects.fx", 0, 0, "PS", "ps_4_0", 0, 0, 0, &PS_Buffer, 0, 0);
hr = D3DX11CompileFromFile("Effects.fx", 0, 0, "D2D_PS", "ps_4_0", 0, 0, 0, &D2D_PS_Buffer, 0, 0);
//Create the Shader Objects
hr = d3d11Device->CreateVertexShader(VS_Buffer->GetBufferPointer(), VS_Buffer->GetBufferSize(), NULL, &VS);
hr = d3d11Device->CreatePixelShader(PS_Buffer->GetBufferPointer(), PS_Buffer->GetBufferSize(), NULL, &PS);
hr = d3d11Device->CreatePixelShader(D2D_PS_Buffer->GetBufferPointer(), D2D_PS_Buffer->GetBufferSize(), NULL, &D2D_PS);
For example above ^ I'm having an issue with the "D2D_PS" lines from the CompileFromFile and the CreatePixelShader, but when the error comes up it just points to the line and comes up with an error like
"Unhandled exception at 0x772815de in DX16UP.exe: 0xC0000005: Access violation reading location 0x00000000."
So I'm just curious if I can put something after the "hr = " lines to do some error handling. I did have some code that was
if(FAILED(hr))
{
MessageBox(NULL, DXGetErrorDesction(?)(hr),
TEXT("Message"), MB_OK);
return 0;
}
The "DXGetError" isn't really what I had but I can't seem to find it at the moment but you get the idea.
EDIT: I'm starting to think this should be in the DirectX section instead of the beginners. Could someone move this?