From ef9b5a48bd91757a3ebc0a4f0006c9f98737c205 Mon Sep 17 00:00:00 2001 From: rodri Date: Sun, 14 Jan 2024 23:10:35 +0000 Subject: add a model of the earth. do texture mapping based on picture format (RGB24, RGBA32 atm.) --- main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index bdb5d95..e59c86f 100644 --- a/main.c +++ b/main.c @@ -285,7 +285,14 @@ rasterize(SUparams *params, Triangle3 st, Triangle2 tt, Memimage *frag) tp.x = (tt₂.p0.x + tt₂.p1.x + tt₂.p2.x)*Dx(modeltex->r); tp.y = (1 - (tt₂.p0.y + tt₂.p1.y + tt₂.p2.y))*Dy(modeltex->r); - unloadmemimage(modeltex, rectaddpt(Rect(0,0,1,1), tp), cbuf+1, sizeof cbuf - 1); + switch(modeltex->chan){ + case RGB24: + unloadmemimage(modeltex, rectaddpt(Rect(0,0,1,1), tp), cbuf+1, sizeof cbuf - 1); + break; + case RGBA32: + unloadmemimage(modeltex, rectaddpt(Rect(0,0,1,1), tp), cbuf, sizeof cbuf); + break; + } }else memset(cbuf+1, 0xFF, sizeof cbuf - 1); -- cgit v1.2.3