From 88da0c946e88ae35efae377a14e69055d32967d1 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 24 Apr 2020 20:37:28 -0700 Subject: tex: clamp to a transparent texture border Even with the MSAA off there were occasional fringes showing up, turns out it's because of the default GL texture wrap mode. --- src/tex.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tex.c b/src/tex.c index b8254e1..b67af17 100644 --- a/src/tex.c +++ b/src/tex.c @@ -153,6 +153,12 @@ tex_t * tex_new(int width, int height, const unsigned char *buf) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + /* transparent border pixels outside of the texture boundaries, this + * eliminates the spurious fringing on some sprites/positions */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameterfv(GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, (float[4]){}); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); glBindTexture(GL_TEXTURE_2D, 0); -- cgit v1.2.3