From 75ee45cc65b35d40355178f48ef0c2d90040b863 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 28 Dec 2025 12:57:52 -0800 Subject: Move memory allocation to the client --- include/swgfx.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'include/swgfx.h') diff --git a/include/swgfx.h b/include/swgfx.h index 94eb359..005359b 100644 --- a/include/swgfx.h +++ b/include/swgfx.h @@ -39,13 +39,13 @@ typedef struct sgPixel { uint8_t r, g, b, a; } sgPixel; typedef struct swgfx swgfx; -swgfx* sgNew(); +size_t sgMem(int width, int height); // Get memory requirements. +swgfx* sgNew(int width, int height, void* mem); void sgDel(swgfx**); // TODO: Write client app first, then implement the functions below in the C file. -void sgColourBuffer(swgfx*, sgVec2i dimensions, sgPixel* buffer); -void sgPresent (swgfx*, sgVec2i dimensions, sgPixel* screen); +void sgPresent(swgfx*, sgVec2i dimensions, sgPixel* screen); void sgModelId (swgfx*); void sgModel (swgfx*, sgVec3 position, sgVec3 right, sgVec3 up, sgVec3 forward); @@ -66,11 +66,3 @@ void sgTrianglesIndexed(swgfx*, size_t numIndices, const sgIdx* indices, const s void sgTrianglesIndexedNonUniform(swgfx*, size_t numTris, const sgTriIdx* tris, const sgVec3* positions); void sgCheck(swgfx*); - -// Memory -#define SG_ALIGN 64 -#define SG_ALIGN_PTR(P) ((uintptr_t)(P) & (~(SG_ALIGN-1))) -#define SG_ALIGN_ALLOC(COUNT, TYPE) (TYPE*)sgAlloc(1, COUNT * sizeof(TYPE)) -#define SG_FREE(PP) sgFree((void**)PP) -void* sgAlloc(size_t count, size_t size); -void sgFree(void**); -- cgit v1.2.3