cocoa/c++ relative path to load resources
- by moka
Hi,
I am currently working directly with cocoa for the first time, to built a screen saver. Now I came across a problem when trying to load resources from within the .saver bundle. I basically have a small c++ wrapper class to load .exr files using freeImage. That works as long as I use absoulte paths, but thats not very useful, is it?
So basically I tried everything, putting the .exr file on the level of the .saver bundle itself, inside the bundles Resources folder and so on.
Then I simply tried to load the .exr like this without success
particleTex = [self loadExrTexture: "ball.exr"];
I also tried making it go to the .saver bundles location like this:
particleTex = [self loadExrTexture: "../../../ball.exr"];
to maybe load the .exr from that location but without success.
I then came across this:
NSString * path = [[NSBundle mainBundle] pathForResource:@"ball" ofType:@"exr"];
const char * pChar = [path UTF8String];
which seems to be a common way to find resources in cocoa, but for some reason its emty in my case. any ideas about that?
I really tried out anything that came to my mind without success so I would be glad about some input!