added locateResource() and ag::ag_loadModel()
git-svn-id: svn://anubis/anaglym/trunk@10 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
795fcc13d6
commit
ed80f25cee
34
ag.cc
34
ag.cc
@ -1,7 +1,10 @@
|
||||
|
||||
#include "anaglym.h"
|
||||
#include "ag.h"
|
||||
#include <iostream>
|
||||
#include "wfobj/WFObj.hh"
|
||||
#include <lua.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
namespace ag
|
||||
@ -11,6 +14,7 @@ namespace ag
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "print", ag_print },
|
||||
{ "println", ag_println },
|
||||
{ "loadModel", ag_loadModel },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
luaL_register(L, "ag", functions);
|
||||
@ -75,7 +79,33 @@ namespace ag
|
||||
|
||||
int ag_println(lua_State * L)
|
||||
{
|
||||
ag_print(L);
|
||||
int ret = ag_print(L);
|
||||
cout << endl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ag_loadModel(lua_State * L)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
if (lua_type(L, -1) == LUA_TSTRING)
|
||||
{
|
||||
string modelname = lua_tostring(L, -1);
|
||||
size_t pos = modelname.find_first_not_of(FILENAME_SAFE_CHARS);
|
||||
if (pos != string::npos)
|
||||
{
|
||||
string path = locateResource(modelname);
|
||||
if (path != "")
|
||||
{
|
||||
WFObj * obj = new WFObj();
|
||||
obj->load(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
1
ag.h
1
ag.h
@ -9,6 +9,7 @@ namespace ag
|
||||
void register_functions(lua_State * L);
|
||||
int ag_print(lua_State * L);
|
||||
int ag_println(lua_State * L);
|
||||
int ag_loadModel(lua_State * L);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
11
anaglym.cc
11
anaglym.cc
@ -1,8 +1,9 @@
|
||||
|
||||
#include <iostream>
|
||||
#include "ag.h"
|
||||
#include <lua.hpp>
|
||||
#include <stdlib.h> /* exit() */
|
||||
#include "ag.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
static void usage();
|
||||
@ -91,3 +92,9 @@ static void register_libraries(lua_State * L)
|
||||
|
||||
ag::register_functions(L);
|
||||
}
|
||||
|
||||
string locateResource(const string & shortname)
|
||||
{
|
||||
/* TODO: fill in */
|
||||
return "";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user