From 1ae1b370da0ce0cf8501b9e6be8c6ac25e249e1a Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Wed, 31 Dec 2025 14:46:33 -0800 Subject: Initial texturing changes --- include/swgfx.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/swgfx.h b/include/swgfx.h index 970e3fa..4a98116 100644 --- a/include/swgfx.h +++ b/include/swgfx.h @@ -38,8 +38,18 @@ typedef uint16_t sgIdx; typedef struct sgVertIdx { sgIdx pos, uv, normal; } sgVertIdx; typedef struct sgTriIdx { sgVertIdx v0, v1, v2; } sgTriIdx; +typedef struct sgBgra { uint8_t b, g, r, a; } sgBgra; +typedef struct sgRgba { uint8_t r, g, b, a; } sgRgba; // TODO: Should we use real-valued colours? -typedef struct sgPixel { uint8_t r, g, b, a; } sgPixel; +typedef sgRgba sgPixel; +// TODO: Expose a macro to control the desired surface format. +typedef sgBgra sgScreenPixel; + +typedef struct sgTexture_t { + int width; + int height; + sgPixel* pixels; +} sgTexture_t; typedef struct swgfx swgfx; @@ -49,7 +59,7 @@ void sgDel(swgfx**); // TODO: Write client app first, then implement the functions below in the C file. -void sgPresent(swgfx*, sgVec2i dimensions, sgPixel* screen); +void sgPresent(swgfx*, sgVec2i dimensions, sgScreenPixel* screen); void sgModelId (swgfx*); void sgModel (swgfx*, sgVec3 position, sgVec3 right, sgVec3 up, sgVec3 forward); @@ -58,6 +68,8 @@ void sgOrtho (swgfx*, R left, R right, R top, R bottom, R near, R far); void sgPerspective(swgfx*, R fovy, R aspect, R near, R far); void sgViewport (swgfx*, int x0, int y0, int width, int height); +void sgTexture(swgfx*, const sgTexture_t*); + void sgClear(swgfx*); void sgPixels(swgfx*, size_t count, const sgVec2i* positions, sgPixel colour); void sgQuads (swgfx*, size_t count, const sgQuad*); -- cgit v1.2.3