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. --- graphics.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'graphics.h') diff --git a/graphics.h b/graphics.h index 3cd070f..39af008 100644 --- a/graphics.h +++ b/graphics.h @@ -24,8 +24,8 @@ enum { LightSpot, /* raster formats */ - COLOR32 = 0, - FLOAT32, + COLOR32 = 0, /* RGBA32 */ + FLOAT32, /* F32 */ /* texture formats */ RAWTexture = 0, /* unmanaged */ @@ -314,7 +314,7 @@ struct Framebufctl void (*draw)(Framebufctl*, Image*, char*, Point, Point); void (*memdraw)(Framebufctl*, Memimage*, char*, Point, Point); void (*swap)(Framebufctl*); - void (*reset)(Framebufctl*, ulong); + void (*reset)(Framebufctl*); void (*createraster)(Framebufctl*, char*, ulong); Raster *(*fetchraster)(Framebufctl*, char*); Framebuf *(*getfb)(Framebufctl*); @@ -350,7 +350,6 @@ struct Camera } clip; Matrix3 proj; /* VCS to clip space xform */ Projection projtype; - ulong clearcolor; int cullmode; int enableblend; int enabledepth; @@ -431,14 +430,20 @@ Color samplecubemap(Cubemap*, Point3, Color(*)(Texture*, Point2)); /* util */ Point2 modulapt2(Point2, Point2); +Point2 minpt2(Point2, Point2); +Point2 maxpt2(Point2, Point2); Point3 modulapt3(Point3, Point3); +Point3 minpt3(Point3, Point3); +Point3 maxpt3(Point3, Point3); Memimage *rgb(ulong); Memimage *dupmemimage(Memimage*); /* color */ +ulong col2ul(Color); +Color ul2col(ulong); +int hasalpha(ulong); Color srgb2linear(Color); Color linear2srgb(Color); -ulong rgba2xrgb(ulong); Color aces(Color); Color aces2(Color); -- cgit v1.2.3