diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-12 00:16:33 +0100 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-12 00:16:33 +0100 |
| commit | 8d63c6c56a3abe69f4801708b0db00dd09e0b2b0 (patch) | |
| tree | d31aabdd1ebce21cb63a8a4f0b2d7955a546ee34 | |
| parent | 11dc980a40b4743b52ad4d88d91659e0cd413794 (diff) | |
quads
| -rw-r--r-- | src/rendering.h | 43 |
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 { |
