From 07fb91b9571fc0add797cbcd0adcc8711401a2be Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 27 Dec 2025 12:00:21 -0800 Subject: Enough stuff to draw a cube --- include/swgfx.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include/swgfx.h') diff --git a/include/swgfx.h b/include/swgfx.h index b6dc769..94eb359 100644 --- a/include/swgfx.h +++ b/include/swgfx.h @@ -1,7 +1,7 @@ /* Software rendering library. -Cooridnate systems: +Coordinate systems: - Pixel coordinates (i,j) refer to the center of the pixel. Thus, real-valued coordinates (x,y) with no fractional part point at the pixel center. - Viewport origin is the top-left corner of the screen. @@ -30,6 +30,10 @@ typedef struct sgQuad { sgVec2 p0, p1; } sgQuad; typedef struct sgTri2 { sgVec2 p0, p1, p2; } sgTri2; typedef struct sgTri3 { sgVec3 p0, p1, p2; } sgTri3; +typedef uint16_t sgIdx; +typedef struct sgVert { sgIdx position, normal, texcoord; } sgVert; +typedef struct sgTriIdx { sgVert v0, v1, v2; } sgTriIdx; + // TODO: Should we use real-valued colours? typedef struct sgPixel { uint8_t r, g, b, a; } sgPixel; @@ -43,7 +47,9 @@ void sgDel(swgfx**); void sgColourBuffer(swgfx*, sgVec2i dimensions, sgPixel* buffer); void sgPresent (swgfx*, sgVec2i dimensions, sgPixel* screen); -void sgCam (swgfx*, sgVec3 position, sgVec3 forward); +void sgModelId (swgfx*); +void sgModel (swgfx*, sgVec3 position, sgVec3 right, sgVec3 up, sgVec3 forward); +void sgView (swgfx*, sgVec3 position, sgVec3 forward); 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); @@ -56,6 +62,8 @@ void sgTriangles2 (swgfx*, size_t count, const sgTri2*); void sgTriangleStrip2(swgfx*, size_t count, const sgVec2*); void sgTriangles (swgfx*, size_t count, const sgTri3*, const sgNormal*); void sgTriangleStrip (swgfx*, size_t count, const sgVec3*, const sgNormal*); +void sgTrianglesIndexed(swgfx*, size_t numIndices, const sgIdx* indices, const sgVec3* positions); +void sgTrianglesIndexedNonUniform(swgfx*, size_t numTris, const sgTriIdx* tris, const sgVec3* positions); void sgCheck(swgfx*); -- cgit v1.2.3