This project has moved and is read-only. For the latest updates, please go here.

Question about Resource File Loading

Oct 28, 2014 at 4:36 AM
Hello!

I have a project set up in which I'm using the DXTK loading functions (such as the SpriteFont constructor and CreateFromCMO, etc.). I am having problems determining how to change where these functions are looking for the files. Right now, Visual Studio 'compiles' the FBX file, and both the cmo and cso files get placed in the output directory of my project. I can also confirm that the project's .exe file gets output to the same folder.

When I run the project, however, I get an 'Unable to find file' exception. If I copy the cmo/cso files into my project directory (the one containing myProject.vcxproj and all my header/cpp files), it finds the resources no problem. The same issue occurs with SpriteFont (and any other methods using the BinaryReader class).

I can't help but think this is just some kind of configuration error in my project, but I have no idea what I'm doing wrong. Any chance anyone could provide some insight on this? Is there some way I can change where the BinaryReader class is looking for the files?
Oct 28, 2014 at 6:23 AM
The file functions in DirectX Tool Kit assume you provide full paths or relative paths from your current working directory. It does not perform any file "searching" as this can cause poor performance. You are of course free to implement your own file searching logic before calling the DirectX Tool Kit functions.

To simplify the texture references from within a CMO or SDKMESH, you can provide a 'prepend path' to EffectFactory (see the docs under Directories).
Oct 30, 2014 at 4:53 AM
I seem to have solved the problem. I was expecting that the tool kit functions would be working as if the root directory was the location of the .exe, but they appear to work out of the project directory. I just set up another folder for 'compiled' resources, like the .cmo/.cso files and set the mesh content exporter to compile to that folder. Also I seem to have all the other files, like .spritefonts, set up to load from the paths they are in correctly.

I appreciate the help :)
Oct 30, 2014 at 9:03 AM
The current working directory when launched by Visual Studio is a project setting (looked under the Debug settings). If you start the EXE directly with a shortcut or clicking in the File Explorer, it will be the same directory as the EXE.
Marked as answer by walbourn on 10/30/2014 at 1:03 AM
Nov 1, 2014 at 5:38 AM
Ah, now I understand, this is exactly what I was looking for. Thanks!