summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-09-11 20:48:13 +0000
committerrodri <rgl@antares-labs.eu>2024-09-11 20:48:13 +0000
commit09ffa3cfc72a10e82c5c68f4010d1c518f0c3328 (patch)
treebe398761d4f406071417a0b021803d494aa90c11 /util.c
parent8806aad87f7be2d2e82c7db2b9f0978246e5a747 (diff)
downloadlibgraphics-09ffa3cfc72a10e82c5c68f4010d1c518f0c3328.tar.gz
libgraphics-09ffa3cfc72a10e82c5c68f4010d1c518f0c3328.tar.bz2
libgraphics-09ffa3cfc72a10e82c5c68f4010d1c518f0c3328.zip
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.
Diffstat (limited to 'util.c')
-rw-r--r--util.c42
1 files changed, 42 insertions, 0 deletions
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)
{