Original Post
I'm setting up an resource loading system and have run into some bizarre issues with the ID3DXEffect and ID3DXInclude interfaces. Essentially, my setup is that an App says LoadEffect(string filename) and the engine does the following: 1. It checks the App's local effect folder and searches for filename. If it finds it, it will load the effect with D3DXCreateEffectFromFile. 2. If not it will search for the file in a custom resource file provided by the App, and will load the effect from system memory using D3DXCreateEffect. 3. If the engine still can't find the file then a default effect, embedded in the engine dll as a resource, will be loaded with D3DXCreateEffectFromResource. Now for this process I pass a ID3DXInclude interface into all the CreateEffect*** functions, which essentially impliments the same type of search for effect include files (except that it looks at the D3DXINCLUDE_TYPE specification, and no default include is made available). Now the include interface works great for the fallback D3DXCreateEffectFromResource method. I pass in a non-existant filename and the default effect loads fine (with its include dependencies). However, the D3DXCreateEffectFromFile method is doing some strange things (if I pass in a valid filename and it attempts to load the effect from disk two things happen that do not seem like they should): 1. First, D3DXCreateEffectFromFile seems to be trying to use the ID3DXInclude interface to load the actual effect file into memory...which would work fine...but... 2. It tries to load it twice...(I set a debugger break point at the beginning of my ID3DXInclude::Open definition and it breaks twice with the filename I passed in originally...not any include file)...and there is a compile error before I can see if it is going to load the "real" include dependencies: assets\metamaterials\sim.fx(1): error X3000: syntax error: unexpected end of file There is nothing wrong with the file since it is the same as the embedded default resource that compiles fine. If I pass a NULL ID3DXInclude interface to the D3DXCreateEffectFromFile function (and place the include files in the folder with the effect) everything works, but this is not desired to be a requirement. This seems like some bizarre behavior to me, I've scoured the DX docs for some info on the compile error and more details on ID3DXInclude but I found nothing. Any ideas?