From 8d63c6c56a3abe69f4801708b0db00dd09e0b2b0 Mon Sep 17 00:00:00 2001 From: Fabrice Date: Thu, 12 Feb 2026 00:16:33 +0100 Subject: quads --- src/rendering.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src') 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 { -- cgit v1.2.3