summaryrefslogtreecommitdiff
path: root/src/primitives.c
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-06-05 18:20:49 -0500
committersanine-a <sanine.not@pm.me>2020-06-05 18:20:49 -0500
commite4dd7978d24f53465c8475bd3a027047b4a53bb8 (patch)
tree5c861830a2f7ad6ed2bcc0f9f04cd504403b3292 /src/primitives.c
parent70784cdb24628e758df27cbe1965ff83102decb0 (diff)
refactor: rename honey_error to honey_result
Diffstat (limited to 'src/primitives.c')
-rw-r--r--src/primitives.c58
1 files changed, 44 insertions, 14 deletions
diff --git a/src/primitives.c b/src/primitives.c
index 4e6d93b..37d549b 100644
--- a/src/primitives.c
+++ b/src/primitives.c
@@ -1,9 +1,39 @@
#include "include/primitives.h"
-enum honey_mesh_result honey_mesh_new_cube(honey_mesh* mesh,
+honey_result honey_mesh_new_textured_plane(honey_mesh* mesh,
float width,
- float height,
- float depth) {
+ float height) {
+ float x0 = 0;
+ float y0 = 0;
+ float x1 = width;
+ float y1 = height;
+
+ float vertices[] = {
+ /* position normal uv */
+ x0, y0, 0, 0, 0, 1, 0, 0,
+ x1, y0, 0, 0, 0, 1, 1, 0,
+ x0, y1, 0, 0, 0, 1, 0, 1,
+ x1, y1, 0, 0, 0, 1, 1, 1 };
+
+ unsigned int indices[] = {
+ 0, 1, 2,
+ 1, 2, 3 };
+
+ unsigned int attrib_sizes[] = { 3, 3, 2 };
+
+ honey_result result = honey_mesh_new(mesh,
+ vertices, 4,
+ 3, attrib_sizes,
+ indices, 6);
+ return result;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+honey_result honey_mesh_new_cube(honey_mesh* mesh,
+ float width,
+ float height,
+ float depth) {
float x0 = 0;
float y0 = 0;
float z0 = 0;
@@ -50,7 +80,7 @@ enum honey_mesh_result honey_mesh_new_cube(honey_mesh* mesh,
x0, y1, z1, 0, 1, 0,
x1, y1, z1, 0, 1, 0 };
- unsigned int indices[] = {
+ unsigned int indices[] = {
0, 1, 2,
1, 2, 3,
4, 5, 6,
@@ -66,20 +96,20 @@ enum honey_mesh_result honey_mesh_new_cube(honey_mesh* mesh,
unsigned int attrib_sizes[] = { 3, 3 };
- enum honey_mesh_result result = honey_mesh_new(mesh,
- vertices, 24,
- 2, attrib_sizes,
- indices, 36);
+ honey_result result = honey_mesh_new(mesh,
+ vertices, 24,
+ 2, attrib_sizes,
+ indices, 36);
return result;
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-enum honey_mesh_result honey_mesh_new_textured_cube(honey_mesh* mesh,
- float width,
- float height,
- float depth) {
+honey_result honey_mesh_new_textured_cube(honey_mesh* mesh,
+ float width,
+ float height,
+ float depth) {
float x0 = 0;
float y0 = 0;
float z0 = 0;
@@ -88,7 +118,7 @@ enum honey_mesh_result honey_mesh_new_textured_cube(honey_mesh* mesh,
float y1 = height;
float z1 = depth;
- float vertices[] = {
+ float vertices[] = {
/* position normal tex coord */
/* back face */
x0, y0, z0, 0, 0, -1, 0, 0,
@@ -142,7 +172,7 @@ enum honey_mesh_result honey_mesh_new_textured_cube(honey_mesh* mesh,
unsigned int attrib_sizes[] = { 3, 3, 2 };
- enum honey_mesh_result result;
+ honey_result result;
result = honey_mesh_new(mesh, vertices, 24,
3, attrib_sizes,
indices, 36);