summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/swgfx.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/include/swgfx.h b/include/swgfx.h
index 452847c..d527f02 100644
--- a/include/swgfx.h
+++ b/include/swgfx.h
@@ -30,8 +30,8 @@ typedef float R;
30 30
31typedef struct sgVec2i { int x, y; } sgVec2i; 31typedef struct sgVec2i { int x, y; } sgVec2i;
32typedef struct sgVec2 { R x, y; } sgVec2; 32typedef struct sgVec2 { R x, y; } sgVec2;
33typedef struct sgVec3 { R x, y, z; } sgVec3; 33typedef struct sgVec3 { union { struct { R r, g, b; }; struct { R x, y, z; }; }; } sgVec3;
34typedef struct sgVec4 { R x, y, z, w; } sgVec4; 34typedef struct sgVec4 { union { struct { R r, g, b, a; }; struct { R x, y, z, w; }; }; } sgVec4;
35 35
36typedef sgVec3 sgNormal; 36typedef sgVec3 sgNormal;
37 37
@@ -50,14 +50,17 @@ typedef uint16_t sgIdx;
50typedef struct sgVertIdx { sgIdx pos, uv, normal; } sgVertIdx; 50typedef struct sgVertIdx { sgIdx pos, uv, normal; } sgVertIdx;
51typedef struct sgTriIdx { sgVertIdx v0, v1, v2; } sgTriIdx; 51typedef struct sgTriIdx { sgVertIdx v0, v1, v2; } sgTriIdx;
52 52
53typedef struct sgBgra { uint8_t b, g, r, a; } sgBgra; 53typedef struct sgRgba { uint8_t r, g, b, a; } sgRgba;
54typedef struct sgRgba { uint8_t r, g, b, a; } sgRgba; 54typedef struct sgBgra { uint8_t b, g, r, a; } sgBgra;
55// TODO: Should we use real-valued colours? 55
56typedef sgVec3 sgColour3;
57typedef sgVec4 sgColour4;
56typedef sgRgba sgPixel; 58typedef sgRgba sgPixel;
57// TODO: Expose a macro to control the desired surface format. 59// TODO: Expose a macro to control the desired surface format.
58typedef sgBgra sgScreenPixel; 60typedef sgBgra sgScreenPixel;
59 61
60typedef uint16_t sgTextureId; 62typedef uint16_t sgTextureId;
63typedef sgRgba sgTexel;
61 64
62typedef enum sgTextureFilter { 65typedef enum sgTextureFilter {
63 sgNearest, 66 sgNearest,
@@ -67,7 +70,7 @@ typedef enum sgTextureFilter {
67typedef struct sgImage { 70typedef struct sgImage {
68 int width; 71 int width;
69 int height; 72 int height;
70 sgPixel* pixels; 73 sgTexel* pixels;
71} sgImage; 74} sgImage;
72 75
73typedef struct swgfx swgfx; 76typedef struct swgfx swgfx;
@@ -87,8 +90,8 @@ void sgDel(swgfx**);
87 90
88// TODO: Write client app first, then implement the functions below in the C file. 91// TODO: Write client app first, then implement the functions below in the C file.
89 92
90sgPixel* sgColourBuffer(swgfx*); 93sgColour4* sgColourBuffer(swgfx*);
91void sgPresent(swgfx*, sgVec2i dimensions, sgScreenPixel* screen); 94void sgPresent(swgfx*, sgVec2i dimensions, sgScreenPixel* screen);
92 95
93void sgModelId (swgfx*); 96void sgModelId (swgfx*);
94void sgModel (swgfx*, sgVec3 position, sgVec3 right, sgVec3 up, sgVec3 forward); 97void sgModel (swgfx*, sgVec3 position, sgVec3 right, sgVec3 up, sgVec3 forward);
@@ -101,7 +104,7 @@ void sgTextureRegister(swgfx*, sgTextureId, const sgImage*, sgTextureFilter);
101void sgTextureActivate(swgfx*, sgTextureId); 104void sgTextureActivate(swgfx*, sgTextureId);
102 105
103void sgClear(swgfx*); 106void sgClear(swgfx*);
104void sgPixels(swgfx*, size_t count, const sgVec2i* positions, sgPixel colour); 107void sgPixels(swgfx*, size_t count, const sgVec2i* positions, sgColour4);
105void sgQuads (swgfx*, size_t count, const sgQuad*); 108void sgQuads (swgfx*, size_t count, const sgQuad*);
106void sgQuadsi(swgfx*, size_t count, const sgQuadi*); 109void sgQuadsi(swgfx*, size_t count, const sgQuadi*);
107void sgTriangles2 (swgfx*, size_t count, const sgTri2*); 110void sgTriangles2 (swgfx*, size_t count, const sgTri2*);
@@ -112,13 +115,13 @@ void sgTrianglesIndexed(swgfx*, size_t numIndices, const sgIdx* indices, const s
112void sgTrianglesIndexedNonUniform(swgfx*, size_t numTris, const sgTriIdx* tris, const sgVec3* positions, const sgVec2* texcoords, const sgVec3* normals); 115void sgTrianglesIndexedNonUniform(swgfx*, size_t numTris, const sgTriIdx* tris, const sgVec3* positions, const sgVec2* texcoords, const sgVec3* normals);
113 116
114void sgLighting(swgfx*); 117void sgLighting(swgfx*);
115void sgAmbient(swgfx*, sgVec3 ambient); 118void sgAmbient (swgfx*, sgColour3);
116// TODO: Implement directional lights. 119void sgDirectional(swgfx*, sgColour3, sgVec3 direction);
117 120
118void sgDepth(swgfx*); 121void sgDepth(swgfx*);
119void sgNormals(swgfx*); 122void sgNormals(swgfx*);
120 123
121void sgGamma (swgfx*, sgPixel*, int width, int height); 124void sgGamma (swgfx*, sgTexel*, int width, int height);
122void sgGammaInv(swgfx*, sgPixel*, int width, int height); 125void sgGammaInv(swgfx*, sgColour4*, int width, int height);
123 126
124sgCounters sgGetCounters(const swgfx*); 127sgCounters sgGetCounters(const swgfx*);