summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-01-14 23:10:35 +0000
committerrodri <rgl@antares-labs.eu>2024-01-14 23:10:35 +0000
commitef9b5a48bd91757a3ebc0a4f0006c9f98737c205 (patch)
treeb2e456a50e1964ffada0132ef46421a23af599df /main.c
parent88b8681339b85e27e3d1d98c867ac3aa0557f780 (diff)
downloadtinyrend-ef9b5a48bd91757a3ebc0a4f0006c9f98737c205.tar.gz
tinyrend-ef9b5a48bd91757a3ebc0a4f0006c9f98737c205.tar.bz2
tinyrend-ef9b5a48bd91757a3ebc0a4f0006c9f98737c205.zip
add a model of the earth. do texture mapping based on picture format (RGB24, RGBA32 atm.)
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 8 insertions, 1 deletions
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);