LuaStack.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include "lua.hpp"
  3. #include "Types.h"
  4. #include "Vec2.h"
  5. #include "Vec3.h"
  6. #include "Mat4.h"
  7. #include "Quat.h"
  8. namespace crown
  9. {
  10. const int32_t LUA_VEC2_BUFFER_SIZE = 4096;
  11. Vec2 vec2_buffer[LUA_VEC2_BUFFER_SIZE];
  12. uint32_t vec2_used = 0;
  13. const int32_t LUA_VEC3_BUFFER_SIZE = 4096;
  14. Vec3 vec3_buffer[LUA_VEC3_BUFFER_SIZE];
  15. uint32_t vec3_used = 0;
  16. const int32_t LUA_MAT4_BUFFER_SIZE = 4096;
  17. Mat4 mat4_buffer[LUA_MAT4_BUFFER_SIZE];
  18. uint32_t mat4_used = 0;
  19. const int32_t LUA_QUAT_BUFFER_SIZE = 4096;
  20. Quat quat_buffer[LUA_QUAT_BUFFER_SIZE];
  21. uint32_t quat_used = 0;
  22. ///
  23. class LuaStack
  24. {
  25. public:
  26. LuaStack(lua_State* L);
  27. void push_bool(bool value);
  28. void push_int(int32_t value);
  29. void push_float(float value);
  30. void push_string(const char* str, size_t len);
  31. void push_vec2(Vec2* v);
  32. void push_vec3(Vec3* v);
  33. void push_mat4(Mat4* m);
  34. void push_quat(Quat* q);
  35. bool get_bool(int32_t index);
  36. int32_t get_int(int32_t index);
  37. float get_float(int32_t index);
  38. const char* get_string(int32_t index);
  39. Vec2* get_vec2(int32_t index);
  40. Vec3* get_vec3(int32_t index);
  41. Mat4* get_mat4(int32_t index);
  42. Quat* get_quat(int32_t index);
  43. private:
  44. lua_State* m_state;
  45. };
  46. } // namespace crown