summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rendering.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/rendering.h b/src/rendering.h
index 67f4682..45a65c4 100644
--- a/src/rendering.h
+++ b/src/rendering.h
@@ -6,6 +6,49 @@
#include "glad.h"
#include "utils.h"
+struct quad_s {
+ vec2 vertices[WAYC_QUAD_NVERTS];
+ u32 indices[WAYC_QUAD_NINDICES];
+};
+
+static inline void wayc_quad_init(quad_s* quad, f32 left, f32 top, f32 right,
+ f32 bottom) {
+ wayc_notnull(quad);
+
+ /*
+ 0 ---- 1
+ | |
+ | |
+ 3 ---- 2
+ */
+
+ // Vertices (CCW order)
+ WAYC_X(quad->vertices[0]) = left;
+ WAYC_Y(quad->vertices[0]) = top;
+
+ WAYC_X(quad->vertices[1]) = right;
+ WAYC_Y(quad->vertices[1]) = top;
+
+ WAYC_X(quad->vertices[2]) = right;
+ WAYC_Y(quad->vertices[2]) = bottom;
+
+ WAYC_X(quad->vertices[3]) = left;
+ WAYC_Y(quad->vertices[3]) = bottom;
+
+ /*
+ Triangles (CCW):
+ 0 1 2
+ 0 2 3
+ */
+
+ quad->indices[0] = 0;
+ quad->indices[1] = 1;
+ quad->indices[2] = 2;
+ quad->indices[3] = 0;
+ quad->indices[4] = 2;
+ quad->indices[5] = 3;
+}
+
// TODO: review all structs and use types
enum image_type_e {