diff options
author | sanine-a <sanine.not@pm.me> | 2020-10-27 14:39:29 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2020-10-27 14:39:29 -0500 |
commit | fc16337c080db7013791bf25ace538546d2779dc (patch) | |
tree | 49550ddf171eb94ab54a1181b7b2bb8f58a49472 /src | |
parent | 3ef1112d085a101aa55d11ff894f1fb515d29c27 (diff) |
add honey.mesh bindings to the honey_setup()
Diffstat (limited to 'src')
-rw-r--r-- | src/honey.c | 3 | ||||
-rw-r--r-- | src/mesh/mesh.c | 16 | ||||
-rw-r--r-- | src/mesh/mesh.h | 3 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/honey.c b/src/honey.c index 950fc25..cc6b980 100644 --- a/src/honey.c +++ b/src/honey.c @@ -76,6 +76,9 @@ bool honey_setup(lua_State** L) honey_setup_shader(*L); lua_setfield(*L, -2, "shader"); + honey_setup_mesh(*L); + lua_setfield(*L, -2, "mesh"); + lua_pushcfunction(*L, honey_exit); lua_setfield(*L, -2, "exit"); diff --git a/src/mesh/mesh.c b/src/mesh/mesh.c index 55de82c..1889bd7 100644 --- a/src/mesh/mesh.c +++ b/src/mesh/mesh.c @@ -1,5 +1,18 @@ #include "mesh.h" +void honey_setup_mesh(lua_State* L) +{ + honey_lua_element mesh_elements[] = { + { "new", HONEY_FUNCTION, { .function = honey_mesh_new } }, + { "draw", HONEY_FUNCTION, { .function = honey_mesh_draw } }, + { "delete", HONEY_FUNCTION, { .function = honey_mesh_delete } }, + }; + + honey_lua_create_table(L, mesh_elements, 3); +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + int honey_mesh_new(lua_State* L) { float* vertices; @@ -58,6 +71,9 @@ int honey_mesh_new(lua_State* L) } glBindVertexArray(0); + + free(attribute_sizes); + return 1; } diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index a82db52..1f3bc3e 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h @@ -16,6 +16,9 @@ typedef struct { unsigned int vertex_array, vertex_buffer, element_buffer; } honey_mesh; +/** @brief Push the mesh bindings to the lua stack. */ +void honey_setup_mesh(); + /** @brief Create a new mesh from vertex and index arrays. * * This function copies the data, so you can safely permit vertices and |