diff options
| author | sanine-a <sanine.not@pm.me> | 2020-10-27 23:23:22 -0500 | 
|---|---|---|
| committer | sanine-a <sanine.not@pm.me> | 2020-10-27 23:23:22 -0500 | 
| commit | f0a6a17e4fba3510c8ba8f6b114012873035a4a1 (patch) | |
| tree | bcc30d768b1ccf515936cc821ac30a21b5ed9ea7 /src/primitives | |
| parent | c3698446644365283fcd3d3f47f3eea67cad8331 (diff) | |
fix minor bugs, add cube primitive binding, and implement basic first-person camera
Diffstat (limited to 'src/primitives')
| -rw-r--r-- | src/primitives/primitives.c | 19 | 
1 files changed, 18 insertions, 1 deletions
| 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);  }  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ | 
