Reputation: 8597
I have been porting my simple engine to OSX. Its written in c++ and uses SDL and SDL_image.
If I put the images next to the final .app file it works fine, but if I build the images in to resources folder inside the .app it wont work. I get an error saying it couldnt open the image.
So my question is if you have image resources in your .app how can yo access them in c++?
Upvotes: 1
Views: 1239
Reputation: 20098
For some reason the Mac version of SDL sets the working directory to the directory containing the application bundle instead of the application bundle's Resources folder. Change the working directory to the Resources folder. Open the SDLMain.m file and modify the setupWorkingDirectory: method so it sets the working directory to the Resources folder. The following code should work:
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
[[NSFileManager defaultManager] changeCurrentDirectoryPath:resourcePath];
Upvotes: 2