void registerEngineLuaAPI(Engine& engine, UniverseContext& ctx, lua_State* L)
{
	lua_pushlightuserdata(L, &ctx);
	lua_setglobal(L, "g_universe_context");

	lua_pushlightuserdata(L, ctx.m_universe);
	lua_setglobal(L, "g_universe");

	lua_pushlightuserdata(L, &engine);
	lua_setglobal(L, "g_engine");

	registerCFunction(
		L,
		"API_getScene",
		LuaWrapper::wrap<decltype(&LuaAPI::getScene), LuaAPI::getScene>);

	registerCFunction(L,
					  "API_setEntityPosition",
					  LuaWrapper::wrap<decltype(&LuaAPI::setEntityPosition),
									   LuaAPI::setEntityPosition>);

	registerCFunction(L,
					  "API_setEntityRotation",
					  LuaWrapper::wrap<decltype(&LuaAPI::setEntityRotation),
									   LuaAPI::setEntityRotation>);

	registerCFunction(L,
					  "API_createComponent",
					  LuaWrapper::wrap<decltype(&LuaAPI::createComponent),
									   LuaAPI::createComponent>);

	registerCFunction(L,
					  "API_setRenderablePath",
					  LuaWrapper::wrap<decltype(&LuaAPI::setRenderablePath),
									   LuaAPI::setRenderablePath>);

	registerCFunction(L,
					  "API_getInputActionValue",
					  LuaWrapper::wrap<decltype(&LuaAPI::getInputActionValue),
									   LuaAPI::getInputActionValue>);
	registerCFunction(L,
					  "API_addInputAction",
					  LuaWrapper::wrap<decltype(&LuaAPI::addInputAction),
									   LuaAPI::addInputAction>);

	registerCFunction(
		L,
		"API_logError",
		LuaWrapper::wrap<decltype(&LuaAPI::logError), LuaAPI::logError>);

	registerCFunction(
		L,
		"API_logInfo",
		LuaWrapper::wrap<decltype(&LuaAPI::logInfo), LuaAPI::logInfo>);

	registerCFunction(L, "API_multVecQuat", &LuaAPI::multVecQuat);
}
Exemple #2
0
static void registerFunctions(Shader* shader, ShaderCombinations* combinations, Renderer* renderer, lua_State* L)
{
	lua_pushlightuserdata(L, combinations);
	lua_setglobal(L, "this");
	lua_pushlightuserdata(L, renderer);
	lua_setglobal(L, "renderer");
	lua_pushlightuserdata(L, shader);
	lua_setglobal(L, "shader");
	registerCFunction(L, "pass", &LuaWrapper::wrap<decltype(&pass), pass>);
	registerCFunction(L, "fs", &LuaWrapper::wrap<decltype(&fs), fs>);
	registerCFunction(L, "vs", &LuaWrapper::wrap<decltype(&vs), vs>);
	registerCFunction(L, "backface_culling", &LuaWrapper::wrap<decltype(&backface_culling), backface_culling>);
	registerCFunction(L, "depth_test", &LuaWrapper::wrap<decltype(&depth_test), depth_test>);
	registerCFunction(L, "alpha_blending", &LuaWrapper::wrap<decltype(&alpha_blending), alpha_blending>);
	registerCFunction(L, "texture_slot", &LuaWrapper::wrap<decltype(&texture_slot), texture_slot>);
	registerCFunction(L, "texture_define", &LuaWrapper::wrap<decltype(&texture_define), texture_define>);
	registerCFunction(L, "atlas", &LuaWrapper::wrap<decltype(&atlas), atlas>);
	registerCFunction(L, "uniform", &LuaWrapper::wrap<decltype(&uniform), uniform>);
}
void registerEngineLuaAPI(Engine& engine, lua_State* L)
{
	lua_pushlightuserdata(L, &engine);
	lua_setglobal(L, "g_engine");

	registerCFunction(L, "API_getEnvironment", &LuaAPI::getEnvironment);


	registerCFunction(L,
					  "API_getMaterialTexture",
					  LuaWrapper::wrap<decltype(&LuaAPI::getMaterialTexture),
									   LuaAPI::getMaterialTexture>);

	registerCFunction(L,
					  "API_getTerrainMaterial",
					  LuaWrapper::wrap<decltype(&LuaAPI::getTerrainMaterial),
									   LuaAPI::getTerrainMaterial>);

	registerCFunction(
		L,
		"API_getScene",
		LuaWrapper::wrap<decltype(&LuaAPI::getScene), LuaAPI::getScene>);

	registerCFunction(L,
					  "API_setEntityPosition",
					  LuaWrapper::wrap<decltype(&LuaAPI::setEntityPosition),
									   LuaAPI::setEntityPosition>);

	registerCFunction(L,
					  "API_setEntityRotation",
					  LuaWrapper::wrap<decltype(&LuaAPI::setEntityRotation),
									   LuaAPI::setEntityRotation>);

	registerCFunction(
		L,
		"API_setEntityLocalRotation",
		LuaWrapper::wrap<decltype(&LuaAPI::setEntityLocalRotation),
						 LuaAPI::setEntityLocalRotation>);

	registerCFunction(L,
					  "API_createComponent",
					  LuaWrapper::wrap<decltype(&LuaAPI::createComponent),
									   LuaAPI::createComponent>);

	registerCFunction(L,
					  "API_setRenderablePath",
					  LuaWrapper::wrap<decltype(&LuaAPI::setRenderablePath),
									   LuaAPI::setRenderablePath>);

	registerCFunction(L,
					  "API_getInputActionValue",
					  LuaWrapper::wrap<decltype(&LuaAPI::getInputActionValue),
									   LuaAPI::getInputActionValue>);
	registerCFunction(L,
					  "API_addInputAction",
					  LuaWrapper::wrap<decltype(&LuaAPI::addInputAction),
									   LuaAPI::addInputAction>);

	registerCFunction(
		L,
		"API_logError",
		LuaWrapper::wrap<decltype(&LuaAPI::logError), LuaAPI::logError>);

	registerCFunction(
		L,
		"API_logInfo",
		LuaWrapper::wrap<decltype(&LuaAPI::logInfo), LuaAPI::logInfo>);

	registerCFunction(L, "API_multVecQuat", &LuaAPI::multVecQuat);
}