diff options
author | sanine <sanine.not@pm.me> | 2022-08-23 22:16:24 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-08-23 22:16:24 -0500 |
commit | 709e1b6e1ce86f8da4fc136747fcefbc6c6057bd (patch) | |
tree | 8f4da8c27526fb056a340a9d2948fdace8341ece /src/glm/transform.c | |
parent | 3afbf2a13b2dada445fb667bf25600407fea480a (diff) |
add basic 3d perspective
Diffstat (limited to 'src/glm/transform.c')
-rw-r--r-- | src/glm/transform.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/glm/transform.c b/src/glm/transform.c index 4dce595..daf75a5 100644 --- a/src/glm/transform.c +++ b/src/glm/transform.c @@ -4,12 +4,16 @@ #include "util/util.h" +int translate(lua_State *L); +int rotate(lua_State *L); int rotate_z(lua_State *L); void setup_transform(lua_State *L, int glm_tbl) { int tbl = hs_create_table(L, + hs_str_cfunc("translate", translate), + hs_str_cfunc("rotate", rotate), hs_str_cfunc("rotate_z", rotate_z), ); @@ -18,6 +22,31 @@ void setup_transform(lua_State *L, int glm_tbl) } +int translate(lua_State *L) +{ + void *m_ptr, *v_ptr; + hs_parse_args(L, hs_user(m_ptr), hs_user(v_ptr)); + mat4 *m = m_ptr; + vec3 *v = v_ptr; + + glm_translate(*m, *v); + return 0; +} + + +int rotate(lua_State *L) +{ + void *m_ptr, *axis_ptr; + lua_Number angle; + hs_parse_args(L, hs_user(m_ptr), hs_num(angle), hs_user(axis_ptr)); + mat4 *m = m_ptr; + vec3 *axis = axis_ptr; + + glm_rotate(*m, angle, *axis); + return 0; +} + + int rotate_z(lua_State *L) { void *src_ptr, *dest_ptr; |