From 09ffa3cfc72a10e82c5c68f4010d1c518f0c3328 Mon Sep 17 00:00:00 2001 From: rodri Date: Wed, 11 Sep 2024 20:48:13 +0000 Subject: change the raster format to RGBA32. draw to any image format. clean up. got rid of the bullshit dance between XRGB32 and RGBA32, now all rasters are RGBA32 and premultiply alpha before loading up an image and drawing over the destination. this lets the user compose their own scenes with correct transparency. no more mediocre clearcolor. as a consequence drawing got slower, but if i get the turbo drawing pool working properly that should go away. textures also take alpha pre-multiplied channels into account, dividing them when sampling, so loading transparent textures will show the correct colors. --- util.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index 7335819..e7a9544 100644 --- a/util.c +++ b/util.c @@ -14,12 +14,54 @@ modulapt2(Point2 a, Point2 b) return (Point2){a.x*b.x, a.y*b.y, a.w*b.w}; } +Point2 +minpt2(Point2 a, Point2 b) +{ + return (Point2){ + min(a.x, b.x), + min(a.y, b.y), + min(a.w, b.w) + }; +} + +Point2 +maxpt2(Point2 a, Point2 b) +{ + return (Point2){ + max(a.x, b.x), + max(a.y, b.y), + max(a.w, b.w) + }; +} + Point3 modulapt3(Point3 a, Point3 b) { return (Point3){a.x*b.x, a.y*b.y, a.z*b.z, a.w*b.w}; } +Point3 +minpt3(Point3 a, Point3 b) +{ + return (Point3){ + min(a.x, b.x), + min(a.y, b.y), + min(a.z, b.z), + min(a.w, b.w) + }; +} + +Point3 +maxpt3(Point3 a, Point3 b) +{ + return (Point3){ + max(a.x, b.x), + max(a.y, b.y), + max(a.z, b.z), + max(a.w, b.w) + }; +} + void memsetf(void *dp, float v, usize len) { -- cgit v1.2.3