diff options
author | rodri <rgl@antares-labs.eu> | 2024-03-06 14:54:52 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-03-06 14:54:52 +0000 |
commit | e848ff8f07c022537fd6b369db8f126251e9b96e (patch) | |
tree | 5bfe7d21531e7c5a241108dff583b8d4d3785720 /texture.c | |
parent | 96eb8b3c74e8d95579dbd8a3727b7c25f4d49ba2 (diff) | |
download | libgraphics-e848ff8f07c022537fd6b369db8f126251e9b96e.tar.gz libgraphics-e848ff8f07c022537fd6b369db8f126251e9b96e.tar.bz2 libgraphics-e848ff8f07c022537fd6b369db8f126251e9b96e.zip |
make the fshader return a Color instead of a Memimage. clean things up.
Diffstat (limited to 'texture.c')
-rw-r--r-- | texture.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -9,7 +9,7 @@ #include "internal.h" /* - * uv-coords belong to the 4th quadrant (v grows bottom-up), + * uv-coords belong to the 1st quadrant (v grows bottom-up), * hence the need to reverse the v coord. */ static Point @@ -44,7 +44,7 @@ cbuf2col(uchar b[4]) } static Color -_memreadpixel(Memimage *i, Point sp) +_memreadcolor(Memimage *i, Point sp) { uchar cbuf[4]; @@ -66,12 +66,18 @@ _memreadpixel(Memimage *i, Point sp) return cbuf2col(cbuf); } +/* + * nearest-neighbour sampler + */ Color neartexsampler(Memimage *i, Point2 uv) { - return _memreadpixel(i, uv2tp(uv, i)); + return _memreadcolor(i, uv2tp(uv, i)); } +/* + * bilinear sampler + */ Color bilitexsampler(Memimage *i, Point2 uv) { @@ -92,8 +98,8 @@ bilitexsampler(Memimage *i, Point2 uv) r.min.y--; r.max.y--; } - c1 = lerp3(_memreadpixel(i, r.min), _memreadpixel(i, Pt(r.max.x, r.min.y)), 0.5); - c2 = lerp3(_memreadpixel(i, Pt(r.min.x, r.max.y)), _memreadpixel(i, r.max), 0.5); + c1 = lerp3(_memreadcolor(i, r.min), _memreadcolor(i, Pt(r.max.x, r.min.y)), 0.5); + c2 = lerp3(_memreadcolor(i, Pt(r.min.x, r.max.y)), _memreadcolor(i, r.max), 0.5); return lerp3(c1, c2, 0.5); } |