2018-03-05 11:51:05 +08:00
|
|
|
#include <lua/lua.h>
|
|
|
|
#include <lua/lauxlib.h>
|
|
|
|
#include <lua/lualib.h>
|
2018-04-27 11:23:09 +08:00
|
|
|
#include "tk.h"
|
2018-03-04 08:32:52 +08:00
|
|
|
#include "demos/resource.h"
|
|
|
|
|
|
|
|
extern void luaL_openlftk(lua_State* L);
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
lua_State* L = luaL_newstate();
|
|
|
|
static uint32_t s_heap_mem[10 * 1024];
|
2018-03-10 08:06:02 +08:00
|
|
|
const char* lua_file = argc == 2 ? argv[1] : "./demo2.lua";
|
2018-03-04 08:32:52 +08:00
|
|
|
|
|
|
|
luaL_openlibs(L);
|
|
|
|
luaL_openlftk(L);
|
|
|
|
|
2018-04-27 11:23:09 +08:00
|
|
|
tk_init(320, 480, s_heap_mem, sizeof(s_heap_mem));
|
2018-03-04 08:32:52 +08:00
|
|
|
resource_init();
|
|
|
|
|
|
|
|
if (luaL_dofile(L, lua_file)) {
|
|
|
|
fprintf(stderr, "%s\n", lua_tostring(L, -1));
|
|
|
|
lua_pop(L, 1);
|
|
|
|
} else {
|
2018-04-27 11:23:09 +08:00
|
|
|
tk_run();
|
2018-03-04 08:32:52 +08:00
|
|
|
}
|
2018-03-09 21:54:46 +08:00
|
|
|
|
2018-03-04 08:32:52 +08:00
|
|
|
lua_close(L);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|