diff options
-rw-r--r-- | render.c | 19 | ||||
-rw-r--r-- | render.h | 3 |
2 files changed, 21 insertions, 1 deletions
@@ -211,6 +211,25 @@ void ren_point(Renderer* r, Colour c, int x, int y) { r->t[x + y * r->vp[0]] = c; } +void ren_rect(Renderer* r, Colour c, const Rect* re) { + Rect rect = *re; + Colour* d; + int s, y, ey, ex; + rect_clipr(&rect, r->clip); + d = &r->t[rect.x + rect.y * r->vp[0]]; + s = r->vp[0] - rect.w; + ex = rect.x + rect.w; + ey = rect.y + rect.h; + for (y = rect.y; y < ey; y++) { + int x; + for (x = rect.x; x < ex; x++) { + *d = blend(*d, c); + d++; + } + d += s; + } +} + #define imp_ren_char(chw, chh, fw, data) \ int i, j, k, l, ex, ey, s; \ Colour* dst; \ @@ -40,7 +40,7 @@ typedef struct Mesh { Mesh_Vert* verts; } Mesh; -typedef struct { +typedef struct Renderer { Colour* t; int* d; int asp, n; @@ -69,6 +69,7 @@ void ren_clearc(Renderer* r, Colour c); void ren_cleard(Renderer* r, int depth); void ren_clip(Renderer* r, const Rect* c); void ren_point(Renderer* r, Colour c, int x, int y); +void ren_rect(Renderer* r, Colour c, const Rect*); void ren_char( Renderer* r, Colour c, |