LuaEnvironment.cpp 698 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. int32_t luaopen_libcrownlua(lua_State* L)
  19. {
  20. LuaEnvironment env(L);
  21. load_vec2(env);
  22. load_vec3(env);
  23. load_mat4(env);
  24. load_quat(env);
  25. load_math(env);
  26. load_mouse(env);
  27. load_keyboard(env);
  28. load_accelerometer(env);
  29. return 1;
  30. }
  31. } // namespace crown