Sign in to follow this  
mososky

D3DX10CreateShaderResourceViewFromResource

Recommended Posts

I am learning DirectX10 from DirectX 9. The function D3DX10CreateShaderResourceViewFromResource functions similar to the D3DXCreateTextureFromResource function from DX9. I am having a problem getting the function to execute. I believe my resource file is setup correctly, but when I execute I am getting an error. I'm finding no examples in text or online for D3DXCreateTextureFromResource. You can see part of my code below, the top instruction works fine, loading the resource view from a file. The bottom one fails. Any ideas on how to troubleshoot this? /////////////////////// hr = D3DX10CreateShaderResourceViewFromFile(gp_VideoEngine->gp_Device, "pic3.bmp", NULL, NULL, &gp_ResourceView[TXR_PIC3], NULL ); if( FAILED( hr ) ){MessageBox(NULL,"Resource View Error", "Error",NULL);return false;} hr = D3DX10CreateShaderResourceViewFromResource(gp_VideoEngine->gp_Device,0,MAKEINTRESOURCE(IMAGE_PIC4),NULL,NULL,&gp_ResourceView[TXR_PIC4], NULL ); if( FAILED( hr ) ){MessageBox(NULL,"Resource View Error", "Error",NULL);return false;}

Share this post


Link to post
Share on other sites
First off, use the Debug Runtimes to get a specific error message for what went wrong. Attempting to debug problems by guessing what the error is won't get you anywhere.

For your specific problem, you're passing 0 as the HMODULE. The docs don't specify this parameter as being optional, and say nothing about passing 0. They specifically state you need to use GetModuleHandle to get the HMODULE you need. Try doing that, see if it helps.

Share this post


Link to post
Share on other sites
Thanks for your reply.

The error message being returned is a generic DirectX E_FAIL message, which is less than useful.

The DirectX9 function D3DXCreateTextureFromResource has similar arguments with regard to the resource module. This is the same syntax I am passing with success (in another program) into that argument. Passing a 0 in as the HMODULE pointer should result in the application seeking the resouce module in the current executing assembly.

Also, I would think that if the function had a real problem with that 0, that the function would fail with E_INVALIDARG message. (invalid argument).

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this