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/camera.c | |
parent | 3afbf2a13b2dada445fb667bf25600407fea480a (diff) |
add basic 3d perspective
Diffstat (limited to 'src/glm/camera.c')
-rw-r--r-- | src/glm/camera.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/glm/camera.c b/src/glm/camera.c new file mode 100644 index 0000000..7180b77 --- /dev/null +++ b/src/glm/camera.c @@ -0,0 +1,30 @@ +#include <lua.h> +#include <honeysuckle.h> +#include <cglm/cglm.h> +#include "util/util.h" + + +int perspective(lua_State *L); + + +void setup_camera(lua_State *L, int glm_tbl) +{ + int tbl = hs_create_table(L, + hs_str_cfunc("perspective", perspective), + ); + + append_table(L, glm_tbl, tbl); + lua_pop(L, 1); +} + + +int perspective(lua_State *L) +{ + lua_Number fov, aspect, near, far; + void *dest_ptr; + hs_parse_args(L, hs_num(fov), hs_num(aspect), hs_num(near), hs_num(far), hs_user(dest_ptr)); + mat4 *dest = dest_ptr; + + glm_perspective(fov, aspect, near, far, *dest); + return 0; +} |