diff options
Diffstat (limited to 'src/cglm_bindings.c')
-rw-r--r-- | src/cglm_bindings.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/cglm_bindings.c b/src/cglm_bindings.c index f8f6c8a..947c394 100644 --- a/src/cglm_bindings.c +++ b/src/cglm_bindings.c @@ -8,6 +8,7 @@ void honey_setup_cglm(lua_State* L) { "norm", HONEY_FUNCTION, { .function = honey_cglm_vec3_norm } }, { "add", HONEY_FUNCTION, { .function = honey_cglm_vec3_add } }, { "adds", HONEY_FUNCTION, { .function = honey_cglm_vec3_adds } }, + { "sub", HONEY_FUNCTION, { .function = honey_cglm_vec3_sub } }, { "mul", HONEY_FUNCTION, { .function = honey_cglm_vec3_mul } }, { "muls", HONEY_FUNCTION, { .function = honey_cglm_vec3_muls } }, { "normalize", HONEY_FUNCTION, { .function = honey_cglm_vec3_normalize } }, @@ -21,6 +22,7 @@ void honey_setup_cglm(lua_State* L) { "norm", HONEY_FUNCTION, { .function = honey_cglm_vec4_norm } }, { "add", HONEY_FUNCTION, { .function = honey_cglm_vec4_add } }, { "adds", HONEY_FUNCTION, { .function = honey_cglm_vec4_adds } }, + { "sub", HONEY_FUNCTION, { .function = honey_cglm_vec4_sub } }, { "mul", HONEY_FUNCTION, { .function = honey_cglm_vec4_mul } }, { "muls", HONEY_FUNCTION, { .function = honey_cglm_vec4_muls } }, { "normalize", HONEY_FUNCTION, { .function = honey_cglm_vec4_normalize } }, @@ -69,15 +71,15 @@ void honey_setup_cglm(lua_State* L) { "set_value", HONEY_FUNCTION, { .function = honey_cglm_array_set_value } }, { "get_value", HONEY_FUNCTION, { .function = honey_cglm_array_get_value } }, { "copy_array", HONEY_FUNCTION, { .function = honey_cglm_array_copy } }, - { "vec3", HONEY_TABLE, { .table = { 10, vec3_elements } } }, - { "vec4", HONEY_TABLE, { .table = { 10, vec4_elements } } }, + { "vec3", HONEY_TABLE, { .table = { 11, vec3_elements } } }, + { "vec4", HONEY_TABLE, { .table = { 11, vec4_elements } } }, { "mat3", HONEY_TABLE, { .table = { 8, mat3_elements } } }, { "mat4", HONEY_TABLE, { .table = { 10, mat4_elements } } }, { "affine", HONEY_TABLE, { .table = { 3, affine_elements } } }, { "camera", HONEY_TABLE, { .table = { 3, camera_elements } } }, }; - honey_lua_create_table(L, cglm_elements, 9); + honey_lua_create_table(L, cglm_elements, 10); } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -202,6 +204,19 @@ int honey_cglm_vec3_add(lua_State* L) /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +int honey_cglm_vec3_sub(lua_State* L) +{ + float* a, *b, *dest; + honey_lua_parse_arguments(L, 3, + HONEY_USERDATA, &a, + HONEY_USERDATA, &b, + HONEY_USERDATA, &dest); + glm_vec3_sub(a, b, dest); + return 0; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + int honey_cglm_vec3_adds(lua_State* L) { float a, *v, *dest; @@ -359,6 +374,19 @@ int honey_cglm_vec4_adds(lua_State* L) /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +int honey_cglm_vec4_sub(lua_State* L) +{ + float* a, *b, *dest; + honey_lua_parse_arguments(L, 3, + HONEY_USERDATA, &a, + HONEY_USERDATA, &b, + HONEY_USERDATA, &dest); + glm_vec4_sub(a, b, dest); + return 0; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + int honey_cglm_vec4_mul(lua_State* L) { float *a, *b, *dest; |