diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:00:21 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:00:21 -0800 |
| commit | 07fb91b9571fc0add797cbcd0adcc8711401a2be (patch) | |
| tree | 2f7c2e7536e92c1fa86c902939ac47bf931da877 /include | |
| parent | 403730174aeaadcf7a8aad842bc5319050411ef9 (diff) | |
Enough stuff to draw a cube
Diffstat (limited to 'include')
| -rw-r--r-- | include/swgfx.h | 12 |
1 files changed, 10 insertions, 2 deletions
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 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Software rendering library. | 2 | Software rendering library. |
| 3 | 3 | ||
| 4 | Cooridnate systems: | 4 | Coordinate systems: |
| 5 | - Pixel coordinates (i,j) refer to the center of the pixel. | 5 | - Pixel coordinates (i,j) refer to the center of the pixel. |
| 6 | Thus, real-valued coordinates (x,y) with no fractional part point at the pixel center. | 6 | Thus, real-valued coordinates (x,y) with no fractional part point at the pixel center. |
| 7 | - Viewport origin is the top-left corner of the screen. | 7 | - Viewport origin is the top-left corner of the screen. |
| @@ -30,6 +30,10 @@ typedef struct sgQuad { sgVec2 p0, p1; } sgQuad; | |||
| 30 | typedef struct sgTri2 { sgVec2 p0, p1, p2; } sgTri2; | 30 | typedef struct sgTri2 { sgVec2 p0, p1, p2; } sgTri2; |
| 31 | typedef struct sgTri3 { sgVec3 p0, p1, p2; } sgTri3; | 31 | typedef struct sgTri3 { sgVec3 p0, p1, p2; } sgTri3; |
| 32 | 32 | ||
| 33 | typedef uint16_t sgIdx; | ||
| 34 | typedef struct sgVert { sgIdx position, normal, texcoord; } sgVert; | ||
| 35 | typedef struct sgTriIdx { sgVert v0, v1, v2; } sgTriIdx; | ||
| 36 | |||
| 33 | // TODO: Should we use real-valued colours? | 37 | // TODO: Should we use real-valued colours? |
| 34 | typedef struct sgPixel { uint8_t r, g, b, a; } sgPixel; | 38 | typedef struct sgPixel { uint8_t r, g, b, a; } sgPixel; |
| 35 | 39 | ||
| @@ -43,7 +47,9 @@ void sgDel(swgfx**); | |||
| 43 | void sgColourBuffer(swgfx*, sgVec2i dimensions, sgPixel* buffer); | 47 | void sgColourBuffer(swgfx*, sgVec2i dimensions, sgPixel* buffer); |
| 44 | void sgPresent (swgfx*, sgVec2i dimensions, sgPixel* screen); | 48 | void sgPresent (swgfx*, sgVec2i dimensions, sgPixel* screen); |
| 45 | 49 | ||
| 46 | void sgCam (swgfx*, sgVec3 position, sgVec3 forward); | 50 | void sgModelId (swgfx*); |
| 51 | void sgModel (swgfx*, sgVec3 position, sgVec3 right, sgVec3 up, sgVec3 forward); | ||
| 52 | void sgView (swgfx*, sgVec3 position, sgVec3 forward); | ||
| 47 | void sgOrtho (swgfx*, R left, R right, R top, R bottom, R near, R far); | 53 | void sgOrtho (swgfx*, R left, R right, R top, R bottom, R near, R far); |
| 48 | void sgPerspective(swgfx*, R fovy, R aspect, R near, R far); | 54 | void sgPerspective(swgfx*, R fovy, R aspect, R near, R far); |
| 49 | void sgViewport (swgfx*, int x0, int y0, int width, int height); | 55 | void sgViewport (swgfx*, int x0, int y0, int width, int height); |
| @@ -56,6 +62,8 @@ void sgTriangles2 (swgfx*, size_t count, const sgTri2*); | |||
| 56 | void sgTriangleStrip2(swgfx*, size_t count, const sgVec2*); | 62 | void sgTriangleStrip2(swgfx*, size_t count, const sgVec2*); |
| 57 | void sgTriangles (swgfx*, size_t count, const sgTri3*, const sgNormal*); | 63 | void sgTriangles (swgfx*, size_t count, const sgTri3*, const sgNormal*); |
| 58 | void sgTriangleStrip (swgfx*, size_t count, const sgVec3*, const sgNormal*); | 64 | void sgTriangleStrip (swgfx*, size_t count, const sgVec3*, const sgNormal*); |
| 65 | void sgTrianglesIndexed(swgfx*, size_t numIndices, const sgIdx* indices, const sgVec3* positions); | ||
| 66 | void sgTrianglesIndexedNonUniform(swgfx*, size_t numTris, const sgTriIdx* tris, const sgVec3* positions); | ||
| 59 | 67 | ||
| 60 | void sgCheck(swgfx*); | 68 | void sgCheck(swgfx*); |
| 61 | 69 | ||
