From 507f02e0e559559ba2e56552e036926c56cc35cc Mon Sep 17 00:00:00 2001 From: quou Date: Wed, 31 Jul 2024 22:10:26 +1000 Subject: ren_texture --- render.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'render.c') diff --git a/render.c b/render.c index 023c33a..c64cef3 100644 --- a/render.c +++ b/render.c @@ -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, -- cgit v1.2.3-54-g00ecf