summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-10-25 15:49:32 -0500
committersanine-a <sanine.not@pm.me>2020-10-25 15:49:32 -0500
commit4a2fbb88b7ccab784837932ab3d84e17bfd3204b (patch)
tree18ccb83ac3509cfbac55bde497b7b46af4d71ce2 /src
parentc5874a0fc256a429b682f14344fca74fd0deab3a (diff)
add a whole bunch of cglm bindings
Diffstat (limited to 'src')
-rw-r--r--src/cglm_bindings.c534
-rw-r--r--src/cglm_bindings.h314
2 files changed, 847 insertions, 1 deletions
diff --git a/src/cglm_bindings.c b/src/cglm_bindings.c
index c50114c..77b8252 100644
--- a/src/cglm_bindings.c
+++ b/src/cglm_bindings.c
@@ -2,13 +2,49 @@
void honey_setup_cglm(lua_State* L)
{
+ honey_lua_element vec3_elements[] = {
+ { "dot", HONEY_FUNC, { .function = honey_cglm_vec3_dot } },
+ { "cross", HONEY_FUNC, { .function = honey_cglm_vec3_cross } },
+ { "square_norm", HONEY_FUNC, { .function = honey_cglm_vec3_square_norm } },
+ { "norm", HONEY_FUNC, { .function = honey_cglm_vec3_norm } },
+ };
+
+ honey_lua_element vec4_elements[] = {
+ { "dot", HONEY_FUNC, { .function = honey_cglm_vec4_dot } },
+ { "norm2", HONEY_FUNC, { .function = honey_cglm_vec4_norm2 } },
+ { "norm", HONEY_FUNC, { .function = honey_cglm_vec4_norm } },
+ { "add", HONEY_FUNC, { .function = honey_cglm_vec4_add } },
+ { "adds", HONEY_FUNC, { .function = honey_cglm_vec4_adds } },
+ { "mul", HONEY_FUNC, { .function = honey_cglm_vec4_mul } },
+ { "muls", HONEY_FUNC, { .function = honey_cglm_vec4_muls } },
+ { "normalize", HONEY_FUNC, { .function = honey_cglm_vec4_normalize } },
+ { "distance", HONEY_FUNC, { .function = honey_cglm_vec4_distance } },
+ { "lerp", HONEY_FUNC, { .function = honey_cglm_vec4_lerp } },
+ };
+
+ honey_lua_element affine_elements[] = {
+ { "translate", HONEY_FUNC, { .function = honey_cglm_translate } },
+ { "scale", HONEY_FUNC, { .function = honey_cglm_scale } },
+ { "rotate", HONEY_FUNC, { .function = honey_cglm_rotate } },
+ };
+
+ honey_lua_element camera_elements[] = {
+ { "perspective", HONEY_FUNC, { .function = honey_cglm_perspective } },
+ { "orthographic", HONEY_FUNC, { .function = honey_cglm_orthographic } },
+ };
+
honey_lua_element cglm_elements[] = {
{ "new_array_zero", HONEY_FUNC, { .function = honey_cglm_new_array_zero } },
{ "set_value", HONEY_FUNC, { .function = honey_cglm_array_set_value } },
{ "get_value", HONEY_FUNC, { .function = honey_cglm_array_get_value } },
+ { "copy_array", HONEY_FUNC, { .function = honey_cglm_array_copy } },
+ { "vec3", HONEY_TABLE, { .table = { 4, vec3_elements } } },
+ { "vec4", HONEY_TABLE, { .table = { 10, vec4_elements } } },
+ { "affine", HONEY_TABLE, { .table = { 3, affine_elements } } },
+ { "camera", HONEY_TABLE, { .table = { 2, camera_elements } } },
};
- honey_lua_create_table(L, cglm_elements, 3);
+ honey_lua_create_table(L, cglm_elements, 5);
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
@@ -54,3 +90,499 @@ int honey_cglm_array_get_value(lua_State* L)
return 1;
}
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_array_copy(lua_State* L) {
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_INT))
+ lua_error(L);
+
+ float* array = lua_touserdata(L, 1);
+ int n = lua_tointeger(L, 2);
+
+ float* copy = lua_newuserdata(L, n*sizeof(float));
+ memcpy(copy, array, n*sizeof(float));
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm vec3 functions
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+int honey_cglm_vec3_dot(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_USERDATA))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+ float* b = lua_touserdata(L, 2);
+
+ float c = glm_vec3_dot(a, b);
+ lua_pushnumber(L, c);
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec3_cross(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_USERDATA))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+ float* b = lua_touserdata(L, 2);
+
+ float* c = lua_newuserdata(L, 3*sizeof(float));
+
+ glm_vec3_cross(a, b, c);
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec3_square_norm(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+
+ float n2 = glm_vec3_norm2(a);
+ lua_pushnumber(L, n2);
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec3_norm(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+
+ float n = glm_vec3_norm(a);
+ lua_pushnumber(L, n);
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm vec4 functions
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+int honey_cglm_vec4_dot(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_USERDATA))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+ float* b = lua_touserdata(L, 2);
+
+ float dot = glm_vec4_dot(a, b);
+ lua_pushnumber(L, dot);
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_norm2(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* v = lua_touserdata(L, 1);
+
+ float norm2 = glm_vec4_norm2(v);
+
+ lua_pushnumber(L, norm2);
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_norm(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* v = lua_touserdata(L, 1);
+
+ float norm = glm_vec4_norm(v);
+
+ lua_pushnumber(L, norm);
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_add(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_USERDATA))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+ float* b = lua_touserdata(L, 2);
+
+ float* dest = lua_newuserdata(L, 4*sizeof(float));
+
+ glm_vec4_add(a, b, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_adds(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_NUM, HONEY_USERDATA))
+ lua_error(L);
+
+ float a = lua_tonumber(L, 1);
+ float* v = lua_touserdata(L, 2);
+
+ float* dest = lua_newuserdata(L, 4*sizeof(float));
+
+ glm_vec4_adds(v, a, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_mul(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_USERDATA))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+ float* b = lua_touserdata(L, 2);
+
+ float* dest = lua_newuserdata(L, 4*sizeof(float));
+
+ glm_vec4_mul(a, b, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_muls(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_NUM, HONEY_USERDATA))
+ lua_error(L);
+
+ float a = lua_tonumber(L, 1);
+ float* v = lua_touserdata(L, 2);
+
+ float* dest = lua_newuserdata(L, 4*sizeof(float));
+
+ glm_vec4_scale(v, a, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_normalize(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* v = lua_touserdata(L, 1);
+
+ glm_vec4_normalize(v);
+
+ return 0;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_distance(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_USERDATA))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+ float* b = lua_touserdata(L, 2);
+
+ float distance = glm_vec4_distance(a, b);
+ lua_pushnumber(L, distance);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_vec4_lerp(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 3, HONEY_USERDATA, HONEY_USERDATA, HONEY_NUM))
+ lua_error(L);
+
+ float* a = lua_touserdata(L, 1);
+ float* b = lua_touserdata(L, 2);
+ float s = lua_tonumber(L, 3);
+
+ float* dest = lua_newuserdata(L, 4*sizeof(float));
+
+ glm_vec4_lerp(a, b, s, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm mat4 functions
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+int honey_cglm_mat4_identity(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* matrix = lua_touserdata(L, 1);
+ glm_mat4_identity(matrix);
+ return 0;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_pick3(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* matrix = lua_touserdata(L, 1);
+
+ float* dest = lua_newuserdata(L, 9*sizeof(float));
+ glm_mat4_pick3(matrix, dest);
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_mul(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA))
+ lua_error(L);
+
+ float* A = lua_touserdata(L, 1);
+ float* B = lua_touserdata(L, 2);
+
+ float* dest = lua_newuserdata(L, 16*sizeof(float));
+
+ glm_mat4_mul(A, B, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_muls(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_NUM, HONEY_USERDATA))
+ lua_error(L);
+
+ float a = lua_tonumber(L, 1);
+ float* M = lua_touserdata(L, 2);
+
+ float* dest = lua_newuserdata(L, 16*sizeof(float));
+ glm_mat4_scale(M, a);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_mulv(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA))
+ lua_error(L);
+
+ float* M = lua_touserdata(L, 1);
+ float* v = lua_touserdata(L, 2);
+
+ float* dest = lua_newuserdata(L, 4*sizeof(float));
+
+ glm_mat4_mulv(M, v, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_trans(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* M = lua_touserdata(L, 1);
+
+ glm_mat4_transpose(M);
+
+ return 0;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_det(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* M = lua_touserdata(L, 1);
+
+ float det = glm_mat4_det(M);
+ lua_pushnumber(L, det);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_trace(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* M = lua_touserdata(L, 1);
+
+ float trace = glm_mat4_trace(M);
+ lua_pushnumber(L, trace);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_inv(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* M = lua_touserdata(L, 1);
+
+ float* dest = lua_newuserdata(L, 16*sizeof(float));
+
+ glm_mat4_inv(M, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_mat4_inv_fast(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 1, HONEY_USERDATA))
+ lua_error(L);
+
+ float* M = lua_touserdata(L, 1);
+
+ float* dest = lua_newuserdata(L, 16*sizeof(float));
+
+ glm_mat4_inv_fast(M, dest);
+
+ return 1;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm 3d affine transforms
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+int honey_cglm_translate(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_USERDATA))
+ lua_error(L);
+
+ float* matrix = lua_touserdata(L, 1);
+ float* vector = lua_touserdata(L, 2);
+
+ glm_translate(matrix, vector);
+ return 0;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_scale(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 2, HONEY_USERDATA, HONEY_USERDATA))
+ lua_error(L);
+
+ float* matrix = lua_touserdata(L, 1);
+ float* vector = lua_touserdata(L, 2);
+
+ glm_scale(matrix, vector);
+ return 0;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_rotate(lua_State* L) {
+ if (!honey_lua_validate_types(L, 4,
+ HONEY_USERDATA, HONEY_USERDATA,
+ HONEY_USERDATA, HONEY_NUM))
+ lua_error(L);
+
+ float* matrix = lua_touserdata(L, 1);
+ float* center = lua_touserdata(L, 2);
+ float* axis = lua_touserdata(L, 3);
+ float angle = lua_tonumber(L, 4);
+
+ glm_rotate_at(matrix, center, angle, axis);
+ return 0;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm camera matrix functions
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+int honey_cglm_perspective(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 5,
+ HONEY_USERDATA,
+ HONEY_NUM, HONEY_NUM,
+ HONEY_NUM, HONEY_NUM))
+ lua_error(L);
+
+ float* matrix = lua_touserdata(L, 1);
+ float fov = lua_tonumber(L, 2);
+ float aspect = lua_tonumber(L, 3);
+ float near = lua_tonumber(L, 4);
+ float far = lua_tonumber(L, 5);
+
+ glm_perspective(fov, aspect, near, far, matrix);
+ return 0;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cglm_orthographic(lua_State* L)
+{
+ if (!honey_lua_validate_types(L, 5,
+ HONEY_USERDATA,
+ HONEY_USERDATA,
+ HONEY_USERDATA))
+
+ lua_error(L);
+
+ float* matrix = lua_touserdata(L, 1);
+ float* a = lua_touserdata(L, 2);
+ float* b = lua_touserdata(L, 3);
+
+ float* box[] = { a, b };
+
+ glm_ortho_aabb(box, matrix);
+ return 0;
+}
diff --git a/src/cglm_bindings.h b/src/cglm_bindings.h
index eaadc98..01e6792 100644
--- a/src/cglm_bindings.h
+++ b/src/cglm_bindings.h
@@ -44,4 +44,318 @@ int honey_cglm_array_set_value(lua_State* L);
*/
int honey_cglm_array_get_value(lua_State* L);
+/** @brief Create a copy of a floating point array.
+ *
+ * @param[in] array The array to copy.
+ * @param[in] n The size of the array.
+ *
+ * @returns A copy of the array.
+ */
+int honey_cglm_array_copy(lua_State* L);
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm vec3 functions
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+/** @brief Dot product of a and b.
+ *
+ * @param[in] a Vector a.
+ * @param[in] b Vector b.
+ *
+ * @returns The result of dot(a, b)
+ */
+int honey_cglm_vec3_dot(lua_State* L);
+
+/** @brief Cross product of a and b.
+ *
+ * @param[in] a Vector a.
+ * @param[in] b Vector b.
+ *
+ * @returns vec3 of cross(a, b).
+ */
+int honey_cglm_vec3_cross(lua_State* L);
+
+/** @brief Compute the square of the norm of a vector.
+ *
+ * This function is useful if you want norm*norm
+ * because it avoids the overhead of two sqrt calls.
+ *
+ * @param a Vector a.
+ *
+ * @returns The square of norm(a).
+ */
+int honey_cglm_vec3_square_norm(lua_State* L);
+
+/** @brief Compute the L2 norm of a vector.
+ *
+ * @param a Vector a.
+ *
+ * @returns The norm(a).
+ */
+int honey_cglm_vec3_norm(lua_State* L);
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm vec4 functions
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+/** @brief Compute the dot product of two vectors.
+ *
+ * @param[in] a Vector a.
+ * @param[in] b Vector b.
+ *
+ * @returns dot(a,b).
+ */
+int honey_cglm_vec4_dot(lua_State* L);
+
+/** @brief Compute the square of the norm of a vector.
+ *
+ * Use this if you are tempted to compute norm*norm;
+ * it avoids the two calls to sqrt.
+ *
+ * @param[in] v The vector to compute norm^2 for.
+ *
+ * @returns norm(v)^2.
+ */
+int honey_cglm_vec4_norm2(lua_State* L);
+
+/** @brief Compute the norm of a vector.
+ *
+ * @param[in] v The vector.
+ *
+ * @returns norm(v).
+ */
+int honey_cglm_vec4_norm(lua_State* L);
+
+/** @brief Add two vectors together.
+ *
+ * @param[in] a The first vector.
+ * @param[in] b The second vector.
+ *
+ * @returns a + b
+ */
+int honey_cglm_vec4_add(lua_State* L);
+
+/** @brief Add a scalar to a vector.
+ *
+ * @param[in] a The scalar.
+ * @param[in] v The vector.
+ *
+ * @returns a + v.
+ */
+int honey_cglm_vec4_adds(lua_State* L);
+
+/** @param Component-wise multiply two vectors together.
+ *
+ * @param a The first vector.
+ * @param b The second vector.
+ *
+ * @returns [ a.x*b.x, a.y*b.y, a.z*b.z, a.w*b.w ]
+ */
+int honey_cglm_vec4_mul(lua_State* L);
+
+/** @brief Multiply a vector by a scalar.
+ *
+ * @param a The scalar.
+ * @param v The vector.
+ *
+ * @returns a*v.
+ */
+int honey_cglm_vec4_muls(lua_State* L);
+
+/** @brief Normalize a vector.
+ *
+ * @param[inout] v The vector.
+ *
+ * @returns Nothing.
+ */
+int honey_cglm_vec4_normalize(lua_State* L);
+
+/** @brief Compute the distance between two vectors.
+ *
+ * @param[in] a The first vector.
+ * @param[in] b The second vector.
+ *
+ * @returns norm(a-b).
+ */
+int honey_cglm_vec4_distance(lua_State* L);
+
+/** @brief Linearly interpolate between two values.
+ *
+ * @param a The first vector.
+ * @param b The second vector.
+ * @param s A scalar.
+ *
+ * @returns a + s*(b-s)
+ */
+int honey_cglm_vec4_lerp(lua_State* L);
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm mat4 functions
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+/** @brief Set a matrix to be the identity matrix.
+ *
+ * @param matrix The matrix to set to the identity.
+ *
+ * @returns Nothing.
+ */
+int honey_cglm_mat4_identity(lua_State* L);
+
+/** @brief Get the upper left of a matrix as a mat3.
+ *
+ * @param matrix The matrix to extract.
+ *
+ * @returns A new matrix containing the upper left 3x3 section of matrix.
+ */
+int honey_cglm_mat4_pick3(lua_State* L);
+
+/** @brief Multiply two mat4s together.
+ *
+ * @param A The first matrix.
+ * @param B The second matrix.
+ *
+ * @returns A*B.
+ */
+int honey_cglm_mat4_mul(lua_State* L);
+
+/** @brief Multiply a matrix by a scalar.
+ *
+ * @param[in] a The scalar.
+ * @param[in] M The matrix.
+ *
+ * @returns Matrix containing a*M.
+ */
+int honey_cglm_mat4_muls(lua_State* L);
+
+/** @brief Multiply a matrix by a column vector.
+ *
+ * @param[in] M The matrix.
+ * @param[in] v The column vector.
+ *
+ * @returns Matrix containing M*v.
+ */
+int honey_cglm_mat4_mulv(lua_State* L);
+
+/** @brief Transpose a matrix.
+ *
+ * @param[inout] M The matrix to transpose.
+ *
+ * @returns Nothing.
+ */
+int honey_cglm_mat4_trans(lua_State* L);
+
+/** @brief Get the determinant of a matrix.
+ *
+ * @param[in] M The matrix.
+ *
+ * @returns det(M).
+ */
+int honey_cglm_mat4_det(lua_State* L);
+
+/** @brief Get the trace of a matrix.
+ *
+ * @param[in] M The matrix.
+ *
+ * @returns trace(M).
+ */
+int honey_cglm_mat4_trace(lua_State* L);
+
+/** @brief Get the inverse of a matrix.
+ *
+ * This is the precise version; use honey_cglm_mat4_inv_fast
+ * for a faster but less precise version.
+ *
+ * @param[in] M The matrix to invert.
+ *
+ * @returns inv(M).
+ */
+int honey_cglm_mat4_inv(lua_State* L);
+
+/** @brief Get the inverse of a matrix.
+ *
+ * This is the fast version; use honey_cglm_mat4_inv
+ * for a slower but more precise version.
+ *
+ * @param[in] M The matrix to invert.
+ *
+ * @returns inv(M).
+ */
+int honey_cglm_mat4_inv_fast(lua_State* L);
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm 3d affine transforms
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+/** @brief Translate a matrix by a vector.
+ *
+ * This function modifies the matrix in place.
+ *
+ * @param[inout] matrix The mat4 to translate.
+ * @param[in] vector The vec3 to translate by.
+ *
+ * @returns Nothing.
+ */
+int honey_cglm_translate(lua_State* L);
+
+/** @brief Scale a matrix by a vector.
+ *
+ * @param[inout] matrix The mat4 to scale.
+ * @param[in] vector The vec3 to scale by.
+ *
+ * @returns Nothing.
+ */
+int honey_cglm_scale(lua_State* L);
+
+/** @brief Rotate a matrix about a given axis.
+ *
+ * @param[inout] matrix The mat4 to rotate.
+ * @param[in] center The vec3 center of rotation.
+ * @param[in] axis The vec3 axis of rotation.
+ * @param[in] angle The angle to rotate by.
+ *
+ * @returns Nothing.
+ */
+int honey_cglm_rotate(lua_State* L);
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * cglm camera matrix functions
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+/** @brief Put perspective projection matrix into float array.
+ *
+ * @param[out] matrix The mat4 to populate.
+ * @param[in] fov The FOV for the camera.
+ * @param[in] aspect The aspect ratio to use with the camera.
+ * @param[in] near Distance to the near clipping plane.
+ * @param[in] far Distance to the far clipping plane.
+ *
+ * @returns Nothing.
+ */
+int honey_cglm_perspective(lua_State* L);
+
+/** @brief Put an orthographic projection matrix into float array.
+ *
+ * @param[out] matrix The mat4 to populate.
+ * @param[in] a The first vector of the AABB bounding box.
+ * @param[in] b The second vector of the AABB bounding box.
+ *
+ * @returns Nothing.
+ */
+int honey_cglm_orthographic(lua_State* L);
+
#endif