floooh / oryol

A small, portable and extensible C++ 3D coding framework
MIT License
2k stars 200 forks source link

On Mac, local FS root: should be Resources directory #249

Open joeld42 opened 7 years ago

joeld42 commented 7 years ago

Right now specifying root: in a localFS path converts to the executable path:

e.g. ioSetup.Assigns.Add("tex:", "root:gamedata/"); file:///some/path/mytestapp.app/Contents/MacOS/gamedata/

However on mac you almost certainly want the resources directory (where bundled files are copied by default). As a workaround you can do:

ioSetup.Assigns.Add("tex:", "root:../Resources/gamedata/"); file:///some/path/mytestapp.app/Contents/MacOS/../Resources/gamedata/

Might also want to add an exe: prefix for the actual executable path.

note: I am going to patch this in my fork, so feel free to assign this to me.

floooh commented 7 years ago

Agreed. I think the fsWrapper::getExecutableDir() method should be renamed to fsWrapper::getRootDir() in this case and can then return the Contents/MacOS xxx.app/Contents/ location (but it should only do this when compiled as an app bundle, not as an command line executable).

I wouldn't add an exe: assign until it is needed by some use case (also I think bin: would be a better name).

Feel free to provide a pull request with your implementation, even if it doesn't meet the suggestions above, I'm happy to take it from there :)

Thanks!