Sign in to follow this  
shultays

problem about D3DXCreateEffectFromFile

Recommended Posts

I have some problems about shaders. when I use this D3DXCreateEffectFromFile( D3DDevice, "Ambient.fx", NULL, NULL, NULL, NULL, &AmbientEffect, NULL); It sets AmbientEffect to NULL and after that it gives exception when it tries to use AmbientEffect. Why is this hapenning? I am using this example http://www.applicachia.com/HLSLAmbientLighting.zip .exe file works fine but I can't compile and run the source file. In one forum people says try to compile .fx file using fxc.exe (in directx sdk utilities folder) but it works fine. I could manage to use the assembly output of fxc.exe in a ps file and it worked fine. I am using visual studio 2008. All another directx examples works fine.Maybe I should configure something in visual studio in order to use HLSL? I copied bin and include directories of directx sdk but nothing else.

Share this post


Link to post
Share on other sites
What is the return value of the function? Also make sure you check the string contained in the ID3DXBuffer return by the ppCompilationErrors parameter, and run with the debug runtimes active.

Share this post


Link to post
Share on other sites
First thing to notice in the example code is that there is no result check. Something like
HRESULT hres = D3DXCreateEffectFromFile( D3DDevice, "Ambient.fx", NULL, NULL, NULL, NULL, &AmbientEffect, NULL );
if(FAILED(hres)) do_something_about_it();


That would tell you the result is E_NOTIMPL. Googling "D3DXCreateEffectFromFile E_NOTIMPL" would bring you back in time, in this forum.

So you can enable backward compatibility, or (what I've done) modify the fx file to compile your ps using ps_2_0 version. Then it works fine.

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