From f0a6a17e4fba3510c8ba8f6b114012873035a4a1 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 27 Oct 2020 23:23:22 -0500 Subject: fix minor bugs, add cube primitive binding, and implement basic first-person camera --- src/primitives/primitives.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/primitives') diff --git a/src/primitives/primitives.c b/src/primitives/primitives.c index 1bfbe14..8293d4d 100644 --- a/src/primitives/primitives.c +++ b/src/primitives/primitives.c @@ -15,13 +15,30 @@ static int honey_mesh_lua_plane(lua_State* L) return 1; } +static int honey_mesh_lua_cube(lua_State* L) +{ + float width, height, depth; + honey_lua_parse_arguments(L, 3, + HONEY_NUMBER, &width, + HONEY_NUMBER, &height, + HONEY_NUMBER, &depth); + + honey_mesh* mesh = lua_newuserdata(L, sizeof(honey_mesh)); + if (honey_mesh_new_textured_cube(mesh, width, height, depth) != HONEY_OK) { + lua_pushstring(L, "error encountered while building plane"); + lua_error(L); + } + return 1; +} + void honey_setup_primitives(lua_State* L) { honey_lua_element primitive_elements[] = { { "plane", HONEY_FUNCTION, { .function = honey_mesh_lua_plane } }, + { "cube", HONEY_FUNCTION, { .function = honey_mesh_lua_cube } }, }; - honey_lua_create_table(L, primitive_elements, 1); + honey_lua_create_table(L, primitive_elements, 2); } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -- cgit v1.2.1