Okay, another dummy question...
The problem is that I want to use some relative path in my game. In the tutorial I have seen something like this
../../media/xyz.ext
and "../" here means up one level
So if I want to get the current level of my application path, what should I do.
For more specific, I have a folder "media" in a same place as my .exe is. What relative path should I use to access the "media" folder? I have tried "media/xyz.ext" and "/media/xyz.ext" but no can work.
Application relative path? [Solved]
Application relative path? [Solved]
Last edited by TnTonly on Wed May 21, 2008 6:31 pm, edited 1 time in total.
After initializing the game, I store the path location of the game executable's working directory.
When I load anything using relative paths, I call this member function first.
And I use a path like:
assets2D\azkat\rooidle_north0000.bmp
Hope this helps.
Code: Select all
m_szExePath =m_pDevice->getFileSystem()->getWorkingDirectory();
Code: Select all
void gmMain::SetFilePathToExeDir()
{
// printf("exe dir=%s\n",m_szExePath);
GAME->GetDevice()->getFileSystem()->changeWorkingDirectoryTo(m_szExePath.c_str());
}
assets2D\azkat\rooidle_north0000.bmp
Hope this helps.
George A Lancaster
Maybe ./your path.. e.g,
Code: Select all
./media/skydomes/skydm1.png
Forgive me if I am missing here something but "../../media/xyz.ext" IS relative path. Unlike for example "D:/project/media/xyz.ext" which tels absolute path.
I am frequently using media folder in my working directory and line "media/xyz.ext" always works fine.
Are you sure it is path which makes file to fail to load?
I am frequently using media folder in my working directory and line "media/xyz.ext" always works fine.
Are you sure it is path which makes file to fail to load?
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Re: Application relative path?
That should work. If you run it via an IDE though, then the working directory may not be the same as the directory that the .exe is in. e.g. the .exe is put in a "Debug" directory, but the working directory is actually the main project directory.TnTonly wrote:For more specific, I have a folder "media" in a same place as my .exe is. What relative path should I use to access the "media" folder? I have tried "media/xyz.ext" and "/media/xyz.ext" but no can work.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way