summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-09-09 21:32:21 +0000
committerrodri <rgl@antares-labs.eu>2024-09-09 21:32:21 +0000
commit5cc40b1dea29dfc40831f69c3f1a8f72a47b5d18 (patch)
treeeb2006b44047447014f38d3e79d89aa6e9d1df9c
parent216f83db15a2c6f28794e4be25165f5ac55270ef (diff)
downloadlibgraphics-5cc40b1dea29dfc40831f69c3f1a8f72a47b5d18.tar.gz
libgraphics-5cc40b1dea29dfc40831f69c3f1a8f72a47b5d18.tar.bz2
libgraphics-5cc40b1dea29dfc40831f69c3f1a8f72a47b5d18.zip
texture: clamp the coordinates instead of aborting when out of bounds.
-rw-r--r--texture.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/texture.c b/texture.c
index b30f829..5d04b89 100644
--- a/texture.c
+++ b/texture.c
@@ -24,7 +24,8 @@ enum {
static Point
uv2tp(Point2 uv, Texture *t)
{
- assert(uv.x >= 0 && uv.x <= 1 && uv.y >= 0 && uv.y <= 1);
+ uv.x = fclamp(uv.x, 0, 1);
+ uv.y = fclamp(uv.y, 0, 1);
return Pt(uv.x*Dx(t->image->r), (1 - uv.y)*Dy(t->image->r));
}