problem about D3DXCreateEffectFromFile

Started by
2 comments, last by shultays 14 years, 10 months ago
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.
taytay
Advertisement
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.
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.
to KOzymandias

thanks! I just changed ps_1_1 to ps_2_0 and it works now.

taytay

This topic is closed to new replies.

Advertisement