added lib directory for standard Anaglym library of models, textures, scripts, etc...

git-svn-id: svn://anubis/anaglym/trunk@69 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-10-12 17:44:30 +00:00
parent 792e087885
commit bddbf61f5f
2 changed files with 21 additions and 1 deletions

View File

@ -16,6 +16,7 @@ using namespace std;
static void usage(); static void usage();
Engine * g_engine; Engine * g_engine;
static string g_engine_path;
SDL_Event Engine::userEvent; SDL_Event Engine::userEvent;
@ -25,8 +26,22 @@ static void usage()
exit(42); exit(42);
} }
static void setupEnginePath(string path)
{
size_t pos = path.find_last_of("\\/");
if (pos != string::npos)
{
g_engine_path = string(path, 0, pos);
}
else
{
g_engine_path = ".";
}
}
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
setupEnginePath(argv[0]);
const char * program = NULL; const char * program = NULL;
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
{ {
@ -164,10 +179,16 @@ string Engine::locateResource(const string & shortname)
{ {
string try_path; string try_path;
/* look for the resource relative to the loaded script's directory */
try_path = m_program_path + "/" + shortname; try_path = m_program_path + "/" + shortname;
if (fileExists(try_path)) if (fileExists(try_path))
return try_path; return try_path;
/* next look for the resource in the engine's library directory */
try_path = g_engine_path + "/lib/" + shortname;
if (fileExists(try_path))
return try_path;
return ""; return "";
} }

View File

@ -10,7 +10,6 @@ end
--ag.setCamera(8, -8, 15, -8, 8, 4, 0, 0, 1) --ag.setCamera(8, -8, 15, -8, 8, 4, 0, 0, 1)
arena = ag.loadStaticModel("boxarena") arena = ag.loadStaticModel("boxarena")
arena:setVisible(false)
ball = ag.loadModel("ball") ball = ag.loadModel("ball")
ball:setPosition(-7, 7.4, 12) ball:setPosition(-7, 7.4, 12)
ball2 = ball:clone() ball2 = ball:clone()