summaryrefslogtreecommitdiff
path: root/src/primitives/primitives.c
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-10-27 15:31:14 -0500
committersanine-a <sanine.not@pm.me>2020-10-27 15:31:14 -0500
commitccd98d4dbdb7acde2433153a01d00a3b9bed02c0 (patch)
tree9ad033d4d6b48d9824a9c924fe23a421feff1f70 /src/primitives/primitives.c
parent50a8d3dc884816fbb1e3a3df3c401358e62b5eea (diff)
fix bug in honey.shader.new and add basic primitives bindings
Diffstat (limited to 'src/primitives/primitives.c')
-rw-r--r--src/primitives/primitives.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/primitives/primitives.c b/src/primitives/primitives.c
index efc4a0f..1bfbe14 100644
--- a/src/primitives/primitives.c
+++ b/src/primitives/primitives.c
@@ -1,5 +1,31 @@
#include "primitives.h"
+static int honey_mesh_lua_plane(lua_State* L)
+{
+ float width, height;
+ honey_lua_parse_arguments(L, 2,
+ HONEY_NUMBER, &width,
+ HONEY_NUMBER, &height);
+
+ honey_mesh* mesh = lua_newuserdata(L, sizeof(honey_mesh));
+ if (honey_mesh_new_textured_plane(mesh, width, height) != 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 } },
+ };
+
+ honey_lua_create_table(L, primitive_elements, 1);
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
honey_result honey_mesh_new_textured_plane(honey_mesh* mesh,
float width,
float height) {