added ag::sleep()
git-svn-id: svn://anubis/anaglym/trunk@22 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
6bb601355b
commit
8817201a27
20
ag.cc
20
ag.cc
@ -3,6 +3,7 @@
|
|||||||
#include "ag.h"
|
#include "ag.h"
|
||||||
#include "Video.h"
|
#include "Video.h"
|
||||||
#include "wfobj/WFObj.hh"
|
#include "wfobj/WFObj.hh"
|
||||||
|
#include <unistd.h> /* usleep() */
|
||||||
#include <lua.hpp>
|
#include <lua.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -18,6 +19,7 @@ namespace ag
|
|||||||
{ "loadModel", loadModel },
|
{ "loadModel", loadModel },
|
||||||
{ "videoStart", videoStart },
|
{ "videoStart", videoStart },
|
||||||
{ "videoStop", videoStop },
|
{ "videoStop", videoStop },
|
||||||
|
{ "sleep", sleep },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
luaL_register(L, "ag", functions);
|
luaL_register(L, "ag", functions);
|
||||||
@ -115,10 +117,28 @@ namespace ag
|
|||||||
int videoStart(lua_State * L)
|
int videoStart(lua_State * L)
|
||||||
{
|
{
|
||||||
g_video->start();
|
g_video->start();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int videoStop(lua_State * L)
|
int videoStop(lua_State * L)
|
||||||
{
|
{
|
||||||
g_video->stop();
|
g_video->stop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sleep(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
if (lua_type(L, -1) == LUA_TNUMBER)
|
||||||
|
{
|
||||||
|
double seconds = lua_tonumber(L, -1);
|
||||||
|
usleep((useconds_t) (seconds * 1000000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user