diff options
author | rodri <rgl@antares-labs.eu> | 2024-07-04 14:57:00 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-07-04 14:57:00 +0000 |
commit | 6d8fbc2953c6ae29ee5162ca04920d6cef85d0ce (patch) | |
tree | 17876fc78176c7877130766ac4b1fcb126062f5a /texture.c | |
parent | 32219aaa35b07d6abceb7df9f802c9758b53eb72 (diff) | |
download | libgraphics-6d8fbc2953c6ae29ee5162ca04920d6cef85d0ce.tar.gz libgraphics-6d8fbc2953c6ae29ee5162ca04920d6cef85d0ce.tar.bz2 libgraphics-6d8fbc2953c6ae29ee5162ca04920d6cef85d0ce.zip |
rough color space conversion implementation.
colors are now properly processed in linear RGB space for
lighting, shading and blending. sRGB is assumed for any
texture sampled and the destination framebuffer.
it's not perfect, but it does the job for now.
Diffstat (limited to 'texture.c')
-rw-r--r-- | texture.c | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -29,18 +29,6 @@ uv2tp(Point2 uv, Memimage *i) } static Color -ul2col(ulong l) -{ - Color c; - - c.a = (l & 0xff)/255.0; - c.b = (l>>8 & 0xff)/255.0; - c.g = (l>>16 & 0xff)/255.0; - c.r = (l>>24 & 0xff)/255.0; - return c; -} - -static Color cbuf2col(uchar b[4]) { Color c; @@ -72,7 +60,11 @@ _memreadcolor(Memimage *i, Point sp) break; } - return cbuf2col(cbuf); + /* TODO + * not all textures require color space conversion. implement a better + * interface to let the user decide. + */ + return srgb2linear(cbuf2col(cbuf)); } /* |