#include "mesh.h" static int honey_mesh_lua_draw(lua_State* L) { honey_mesh* mesh; int shader; honey_lua_parse_arguments(L, 2, HONEY_USERDATA, &mesh, HONEY_INTEGER, &shader); honey_mesh_draw(*mesh, shader); return 0; } static int honey_mesh_lua_delete(lua_State* L) { honey_mesh* mesh; honey_lua_parse_arguments(L, 1, HONEY_USERDATA, &mesh); honey_mesh_delete(*mesh); return 0; } void honey_setup_mesh(lua_State* L) { honey_lua_element mesh_elements[] = { { "draw", HONEY_FUNCTION, { .function = honey_mesh_lua_draw } }, { "delete", HONEY_FUNCTION, { .function = honey_mesh_lua_delete } }, }; honey_lua_create_table(L, mesh_elements, 2); } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ honey_result honey_mesh_new(honey_mesh* mesh, float* vertices, unsigned int n_vertices, unsigned int n_attributes, unsigned int* attribute_sizes, unsigned int* indices, unsigned int n_indices) { if (vertices == NULL || n_vertices == 0) { return HONEY_MESH_BAD_VERTEX_DATA; } if (indices == NULL || n_indices == 0) { return HONEY_MESH_BAD_INDEX_DATA; } unsigned int vertex_size = 0; for (int i=0; i