LuaEnvironment.cpp 748 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "LuaEnvironment.h"
  2. namespace crown
  3. {
  4. LuaEnvironment::LuaEnvironment(lua_State* L) :
  5. m_state(L)
  6. {
  7. }
  8. //-----------------------------------------------------------
  9. void LuaEnvironment::load_module_function(const char* module, const char* name, const lua_CFunction func)
  10. {
  11. luaL_Reg entry[2];
  12. entry[0].name = name;
  13. entry[0].func = func;
  14. entry[1].name = NULL;
  15. entry[1].func = NULL;
  16. luaL_register(m_state, module, entry);
  17. }
  18. extern "C"
  19. {
  20. int32_t luaopen_libcrownlua(lua_State* L)
  21. {
  22. LuaEnvironment env(L);
  23. load_vec2(env);
  24. load_vec3(env);
  25. load_mat4(env);
  26. load_quat(env);
  27. load_math(env);
  28. load_mouse(env);
  29. load_keyboard(env);
  30. load_accelerometer(env);
  31. load_device(env);
  32. return 1;
  33. }
  34. } // extern "C"
  35. } // namespace crown