[iOS] Load Textures/Images outside of WorkingDirectory

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
IrrlichtForiOS
Posts: 61
Joined: Mon Oct 08, 2012 1:46 pm

[iOS] Load Textures/Images outside of WorkingDirectory

Post by IrrlichtForiOS »

Hi Guys,

developing a new Irrlicht based App, we need to load an image as a Background texture, which is placed in an other directory as the irrlichtDevice's workingDirectory.

Is it possible to switch the workingDirectory to load this images, or is it possible to access directories outside of the workingDirectory?

Example:
- App Sandbox
------ Documents
----------- background.png
------ App-Data
----------- media (the working Directory)
----------------- all other textures

Regards,

Daniel
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: [iOS] Load Textures/Images outside of WorkingDirectory

Post by Nadro »

It's possible. You can do something like that:

Code: Select all

core::stringc filePath = [[[NSBundle mainBundle] resourcePath] UTF8String];
filePath += "/Documents/background.png";
or something like that (if you don't want to use objc):

Code: Select all

path filePath = irrDevice->getFileSystem()->getWorkingDirectory(); // AFAIK at default working dir is set to resources path, but I may be wrong
filePath += "../Documents/background.png";
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
IrrlichtForiOS
Posts: 61
Joined: Mon Oct 08, 2012 1:46 pm

Re: [iOS] Load Textures/Images outside of WorkingDirectory

Post by IrrlichtForiOS »

Nadro wrote:It's possible. You can do something like that:

Code: Select all

core::stringc filePath = [[[NSBundle mainBundle] resourcePath] UTF8String];
filePath += "/Documents/background.png";
or something like that (if you don't want to use objc):

Code: Select all

path filePath = irrDevice->getFileSystem()->getWorkingDirectory(); // AFAIK at default working dir is set to resources path, but I may be wrong
filePath += "../Documents/background.png";
Thanks Nadro! We just found out, that it's possible to switch the directory while runtime.

Code: Select all

stringc workingDir = device->getFileSystem()->getWorkingDirectory();
            
            device->getFileSystem()->changeWorkingDirectoryTo(FAAppFrame::getFassadenBilderDirectory());
            
            //LOAD IMAGE FOR BACKGROUND
            loadImage = new E3DCLoadImage(device, smgr);
            loadImage->loadImageForBackground(FAAppFrame::getCurrentFassadenBildName());
            
            device->getFileSystem()->changeWorkingDirectoryTo(workingDir);
Post Reply