Jump to content
  • Advertisement
Sign in to follow this  
tscott1213

D3DXCreateEffectFromFile Compilation Errors

This topic is 4884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello All, I am loading an effect using the D3DXCreateEffectFromFile() function. The function returns success but the final paramater (the pointer to compilation errors) has values in it. What do I do with it? Are there functions so that I can see what messages or errors are being returned? Thanks Todd

Share this post


Link to post
Share on other sites
Advertisement
Hi there tscott1213,
How are you doing?


[HRESULT WINAPI D3DXCreateEffectFromFile()]
"Create an effect from an ASCII or binary effect description."

[Notes on the return value]
Return Value:
If the function succeeds, the return value is D3D_OK.
If the function fails, the return value can be one of the following:

D3DERR_INVALIDCALL The method call is invalid. For example, a method's parameter may have an invalid value.

D3DXERR_INVALIDDATA The data is invalid.

E_OUTOFMEMORY Microsoft Direct3D could not allocate sufficient memory to complete the call.

So what are we saying here?
We are saying that the return value for D3DXCreateEffectFromFile() can be used to check if the method succeeded and if it didn't you can check the return value for what error occured.

You can look at the reference on directX HResult return values here

You could do
[source lang = c++]
HRESULT hResult = D3DXCreateEffectFromFile(...);
//and then check the result.. or you could just do
if(FAILED(D3DXCreateEffectFile(..))
{
MessageBox.Show(...)//display an error
}



I hope you find some value in this :)
take care, if you have any further questions, please do not hesitate to ask.

Share this post


Link to post
Share on other sites
hi there.
the buffer is a pointer to a (in this case) a string, so you could just type cast it to (char*) and then dump it to a file.

som pseudo code:



ID3DXBuffer *pBuffer = NULL;
D3DXCreateEffectFromFile(,..,..,.&pBuffer);

if(pBuffer != NULL)
{
ofstream file("dump.txt");
file << *((char*)pBuffer->GetBuffer()); // << not sure on this function name , check in the DXSDK (ID3DXBuffer or LPD3DXBUFFER)
file.close();
}





maybe there is a warning or something like that.

Share this post


Link to post
Share on other sites
You can also try compiling it in a shader IDE like FXComposer or RenderMonkey. Then, you can easily see the error messages, fix the code, and re-compile. In my opinion, it's much easier than correcting errors through an engine-like application.

Share this post


Link to post
Share on other sites
Hey guys,

Thanks for the help...this is exactly what I needed.

Interestingly, I did compile the FX file in FxComposer before loading it in the engine. I had compiled the pixel and vertex shaders at version 1.1, while it compiled with no problem I had to increase the version to 2.x in order for it to work in the engine.

I will check out the error messages when I get home tonight (now that you all told me how to!). However, I am using a rather large volume texture in the shader and I imagine that that has something to do with the errors.

Thanks again
This site rocks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!