Exemple #1
0
void pixel_start(int w, int h, const char *start) {
	lua_State *L = luaL_newstate();
	luaL_checkversion(L);
	lua_atpanic(L, _panic);
	luaL_openlibs(L);
	luaX_loader(L);

	pixel_init(L);

	pixel_log("version:%d\n", shader_version());

	memset(&P, 0, sizeof P);
	P.L = L;
	P.fps = PIXEL_FPS;
	P.w = w;
	P.h = h;
	P.s = 1.0f;
	screen_init(P.w, P.h, P.s);
	lua_pushcfunction(L, traceback);
	int tb = lua_gettop(L);
	if (LUA_OK != luaL_loadstring(L, start_script)) {
		pixel_log("%s\n", lua_tostring(L, -1));
	}
	lua_pushstring(L, start);
	if (LUA_OK != lua_pcall(L, 1, 0, tb)) {
		pixel_log("lua_init:%s\n", lua_tostring(L, -1));
	}
	lua_pop(L, 1);
	lua_getfield(L, LUA_REGISTRYINDEX, PIXEL_INIT);
	lua_call(L, 0, 0);
	assert(lua_gettop(L) == 0);
	lua_pushcfunction(L, traceback);
	lua_getfield(L, LUA_REGISTRYINDEX, PIXEL_UPDATE);
	lua_getfield(L, LUA_REGISTRYINDEX, PIXEL_FRAME);
}
Exemple #2
0
static int
lversion(lua_State *L) {
	lua_pushinteger(L, shader_version());
	return 1;
}