diff options
author | quou <quou@disroot.org> | 2024-07-31 22:10:26 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-07-31 22:10:26 +1000 |
commit | 507f02e0e559559ba2e56552e036926c56cc35cc (patch) | |
tree | 2ea085f70d88a46c7fcf499f678408d30549a932 | |
parent | 78a0ff9e5993b4cd826684b52b79604bf02ece25 (diff) |
ren_texture
-rw-r--r-- | render.c | 26 | ||||
-rw-r--r-- | render.h | 5 |
2 files changed, 31 insertions, 0 deletions
@@ -478,6 +478,32 @@ step: } } +void ren_texture( + Renderer* r, + const Rect* re, + const Texture* t +) { + 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 v = (y << fbits) / re->h; + int x; + for (x = rect.x; x < ex; x++) { + int u = (x << fbits) / re->w; + Colour c = sample_tex(t, u, v); + *d = blend(*d, c); + d++; + } + d += s; + } +} + void ren_tri( Renderer* r, const int* iv0, @@ -107,6 +107,11 @@ void ren_line( const int* s, const int* e ); +void ren_texture( + Renderer* r, + const Rect* re, + const Texture* t +); /* Vertex format: * x y z u v r g b * All fixed point values with 9 bits of precision. |