summaryrefslogtreecommitdiff
path: root/src/glm/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glm/setup.c')
-rw-r--r--src/glm/setup.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/glm/setup.c b/src/glm/setup.c
new file mode 100644
index 0000000..a36eeb1
--- /dev/null
+++ b/src/glm/setup.c
@@ -0,0 +1,41 @@
+#include <lua.h>
+#include <lauxlib.h>
+#include "util/util.h"
+#include "glm.h"
+
+
+const char *glm_mat2_tname = "glm.mat2";
+const char *glm_mat3_tname = "glm.mat3";
+const char *glm_mat4_tname = "glm.mat4";
+const char *glm_vec2_tname = "glm.vec2";
+const char *glm_vec3_tname = "glm.vec3";
+const char *glm_vec4_tname = "glm.vec4";
+
+
+void setup_glm(lua_State *L, int honey_index)
+{
+ struct honey_tbl_t glm[] = {
+ #define X(name, func) H_FUNC(name, func),
+ GLM_FUNCTIONS
+ #undef X
+ H_END,
+ };
+ create_table(L, glm);
+ lua_setfield(L, honey_index, "glm");
+}
+
+
+void array_get(lua_State *L, int max, float *array, int index)
+{
+ if (index < 0 || index >= max)
+ luaL_error(L, "index %d is out of range [0-%d]", index, max-1);
+ lua_pushnumber(L, array[index]);
+}
+
+
+void array_set(lua_State *L, int max, float *array, int index, float value)
+{
+ if (index < 0 || index >= max)
+ luaL_error(L, "index %d is out of range [0-%d]", index, max-1);
+ array[index] = value;
+}