awtk/lua/run_lua.c
2018-03-18 11:29:31 +08:00

31 lines
614 B
C

#include <lua/lua.h>
#include <lua/lauxlib.h>
#include <lua/lualib.h>
#include "lftk.h"
#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];
const char* lua_file = argc == 2 ? argv[1] : "./demo2.lua";
luaL_openlibs(L);
luaL_openlftk(L);
lftk_init(320, 480, s_heap_mem, sizeof(s_heap_mem));
resource_init();
if (luaL_dofile(L, lua_file)) {
fprintf(stderr, "%s\n", lua_tostring(L, -1));
lua_pop(L, 1);
} else {
lftk_run();
}
lua_close(L);
return 0;
}