From c6f43d9254a82fcebcda4bcf0e692ff859ba8101 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Sun, 25 Oct 2020 15:58:50 -0500 Subject: add new cglm bindings to honey.cglm --- src/cglm_bindings.c | 60 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/cglm_bindings.c b/src/cglm_bindings.c index 77b8252..10c44cc 100644 --- a/src/cglm_bindings.c +++ b/src/cglm_bindings.c @@ -3,48 +3,62 @@ 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 } }, + { "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 } }, + { "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 } }, + { "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 } }, + { "distance", HONEY_FUNC, { .function = honey_cglm_vec4_distance } }, + { "lerp", HONEY_FUNC, { .function = honey_cglm_vec4_lerp } }, + }; + + honey_lua_element mat4_elements[] = { + { "identity", HONEY_FUNC, { .function = honey_cglm_mat4_identity } }, + { "pick3", HONEY_FUNC, { .function = honey_cglm_mat4_pick3 } }, + { "mul", HONEY_FUNC, { .function = honey_cglm_mat4_mul } }, + { "muls", HONEY_FUNC, { .function = honey_cglm_mat4_muls } }, + { "mulv", HONEY_FUNC, { .function = honey_cglm_mat4_mulv } }, + { "trans", HONEY_FUNC, { .function = honey_cglm_mat4_trans } }, + { "det", HONEY_FUNC, { .function = honey_cglm_mat4_det } }, + { "trace", HONEY_FUNC, { .function = honey_cglm_mat4_trace } }, + { "inv", HONEY_FUNC, { .function = honey_cglm_mat4_inv } }, + { "inv_fast", HONEY_FUNC, { .function = honey_cglm_mat4_inv_fast } }, }; 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 } }, + { "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 } }, + { "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 } } }, + { "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 } } }, + { "mat4", HONEY_TABLE, { .table = { 10, mat4_elements } } }, + { "affine", HONEY_TABLE, { .table = { 3, affine_elements } } }, + { "camera", HONEY_TABLE, { .table = { 2, camera_elements } } }, }; - honey_lua_create_table(L, cglm_elements, 5); + honey_lua_create_table(L, cglm_elements, 9); } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -- cgit v1.2.1