• Create Account

### #Actualclb

Posted 02 October 2012 - 07:54 AM

Programming is not a "play a psychic and guess the errors without checking" game!

1. D3DX11CompileFromFile returns a HRESULT value that tells the error reason if one occurred. Why make life hard on yourself (and the forum posters) and try to guess the error, when you can actually just ask what it was?

2. You ask D3DX11CompileFromFile to create you the blobs VS and PS. Why do you blindly trust it to do so? I don't think anyone loves Microsoft that much to believe their code is bug-free! You should check their end of the deal, namely, test that the function assigned to VS and PS, and that it's non-null:
ID3D10Blob *VS = 0;
if (!VS)
{
printf("D3DX11CompileFromFile failed to generate ID3D10Blob!\n");
clean up and abort;
}


3. Do you really trust Microsoft enough that even if the function manages to return you a valid blob, that it actually contains anything?
if (VS->GetBufferPointer() == 0 || VS->GetBufferSize() == 0)
{
printf("Error: Generated shader blob was empty!\n");
clean up and return;
}


4. Do you trust the CreateVertex/PixelShader function to always succeed? It also returns a HRESULT.

5. Do you trust the outputted pVS/pPS pointers to be valid?

I recommend you first make your program print out "Error: The file shaders.hlsl was not found!" and benignly failing before actually trying to locate why you fail to load it. The file shaders.hlsl should contain your HLSL shader program code. You need to write it yourself (or copy from whatever tutorial/sample you're following). When dealing with relative paths, using _getcwd to double-check the current working directory is helpful to diagnose where exactly the relative path is being looked at.

### #3clb

Posted 02 October 2012 - 05:42 AM

Programming is not a "play a psychic and guess the errors without checking" game!

1. D3DX11CompileFromFile returns a HRESULT value that tells the error reason if one occurred. Why make life hard on yourself (and the forum posters) and try to guess the error, when you can actually just ask what it was?

2. You ask D3DX11CompileFromFile to create you the blobs VS and PS. Why do you blindly trust it to do so? I don't think anyone loves Microsoft that much to believe their code is bug-free! You should check their end of the deal, namely, test that the function assigned to VS and PS, and that it's non-null:
ID3D10Blob *VS = 0;
if (!VS)
{
printf("D3DX11CompileFromFile failed to generate ID3D10Blob!\n");
clean up and abort;
}


3. Do you really trust Microsoft enough that even if the function manages to return you a valid blob, that it actually contains anything?
if (VS->GetBufferPointer() == 0 || VS->GetBufferSize() == 0)
{
printf("Error: Generated shader blob was empty!\n");
clean up and return;
}


4. Do you trust the CreateVertex/PixelShader function to always succeed? It also returns a HRESULT.

5. Do you trust the outputted VS/PS pointers to be valid?

I recommend you first make your program print out "Error: The file shaders.hlsl was not found!" and benignly failing before actually trying to locate why you fail to load it. The file shaders.hlsl should contain your HLSL shader program code. You need to write it yourself (or copy from whatever tutorial/sample you're following). When dealing with relative paths, using _getcwd to double-check the current working directory is helpful to diagnose where exactly the relative path is being looked at.

### #2clb

Posted 02 October 2012 - 05:41 AM

Programming is not a "play a psychic and guess the errors without checking" game!

1. D3DX11CompileFromFile returns a HRESULT value that tells the error reason if one occurred. Why make life hard on yourself (and the forum posters) and try to guess the error, when you can actually just ask what it was?

2. You ask D3DX11CompileFromFile to create you the blobs VS and PS. Why do you blindly trust it to do so? I don't think anyone loves Microsoft that much to believe their code is bug-free! You should check their end of the deal, namely, test that the function assigned to VS and PS, and that it's non-null:
ID3D10Blob *VS = 0;
if (!VS)
{
printf("D3DX11CompileFromFile failed to generate ID3D10Blob!\n");
clean up and abort;
}


3. Do you really trust Microsoft enough that even if the function manages to return you a valid blob, that it actually contains anything?
if (VS->GetBufferPointer() == 0 || VS->GetBufferSize() == 0)
{
printf("Error: Generated shader blob was empty!\n");
clean up and return;
}


4. Do you trust the CreateVertex/PixelShader function to always succeed? It also returns a HRESULT.

5. Do you trust the outputted VS/PS pointers to be valid?

I recommend you first make your program print out "Error: The file shaders.hlsl was not found!" and benignly failing before actually trying to locate why you fail to load it. The file shaders.hlsl should contain your HLSL shader program code. You need to write it yourself (or copy from whatever tutorial/sample you're following). When dealing with relative paths, using _getcwd http://msdn.microsof...y/sf98bd4y.aspx to double-check the current working directory is helpful to diagnose where exactly the relative path is being looked at.

### #1clb

Posted 02 October 2012 - 05:40 AM

Programming is not a "play a psychic and guess the errors without checking" game!

1. D3DX11CompileFromFile returns a HRESULT value that tells the error reason if one occurred: http://msdn.microsoft.com/en-us/library/windows/desktop/ff476261(v=vs.85).aspx . Why make life hard on yourself (and the forum posters) and try to guess the error, when you can actually just ask what it was?

2. You ask D3DX11CompileFromFile to create you the blobs VS and PS. Why do you blindly trust it to do so? I don't think anyone loves Microsoft that much to believe their code is bug-free! You should check their end of the deal, namely, test that the function assigned to VS and PS, and that it's non-null:
ID3D10Blob *VS = 0;
if (!VS)
{
printf("D3DX11CompileFromFile failed to generate ID3D10Blob!\n");
clean up and abort;
}


3. Do you really trust Microsoft enough that even if the function manages to return you a valid blob, that it actually contains anything?
if (VS->GetBufferPointer() == 0 || VS->GetBufferSize() == 0)
{
printf("Error: Generated shader blob was empty!\n");
clean up and return;
}


4. Do you trust the CreateVertex/PixelShader function to always succeed? It also returns a HRESULT http://msdn.microsoft.com/en-us/library/windows/desktop/ff476524(v=vs.85).aspx

5. Do you trust the outputted VS/PS pointers to be valid?

I recommend you first make your program print out "Error: The file shaders.hlsl was not found!" and benignly failing before actually trying to locate why you fail to load it. The file shaders.hlsl should contain your HLSL shader program code. You need to write it yourself (or copy from whatever tutorial/sample you're following). When dealing with relative paths, using _getcwd http://msdn.microsoft.com/en-us/library/sf98bd4y.aspx to double-check the current working directory is helpful to diagnose where exactly the relative path is being looked at.

PARTNERS