summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-04-24 20:37:28 -0700
committerVito Caputo <vcaputo@pengaru.com>2020-04-24 20:37:28 -0700
commit88da0c946e88ae35efae377a14e69055d32967d1 (patch)
treefe59775c0b21dc32488088ce84545815aafcb7ea
parentdb2e899b22aafd0086c03dfb01afda5f2fa285aa (diff)
tex: clamp to a transparent texture borderrev2
Even with the MSAA off there were occasional fringes showing up, turns out it's because of the default GL texture wrap mode.
-rw-r--r--src/tex.c6
1 files changed, 6 insertions, 0 deletions
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);
© All Rights Reserved