3
\$\begingroup\$

having the same issue as this: Why do my sprites have a dark shadow/line/frame surrounding the texture? however, when I do the fix suggested there (changing GL_SRC_ALPHA to GL_ONE) it just replaces the black border with a white border on the images. was able to find a lot of results on google from people finding black borders and fixing it with the GL_ONE change, but no results for white borders. any ideas?

heres some of my relevant code.

init:

glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glAlphaFunc(GL_GREATER, 0.01);
glEnable(GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

when each texture is loaded:

glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, surface->w, surface->h, GL_BGRA, GL_UNSIGNED_BYTE, surface->pixels);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

thanks!

\$\endgroup\$
2
  • \$\begingroup\$ Have you tried messing around with texture clamping? Is your surface size a power of 2 in each dimension? \$\endgroup\$ Nov 4, 2013 at 19:27
  • \$\begingroup\$ yeah I've played around with clamping and having seen any changes. i tried GL_CLAMP and GL_REPEAT. and yeah most of my textures are power of 2 in both directions, both the ones that aren't and the ones that are both have the black/white border \$\endgroup\$
    – Dylan
    Nov 5, 2013 at 2:10

1 Answer 1

3
\$\begingroup\$

It seems you are using non-power of 2 texture dimensions and mipmapping which calls for trouble because the minifying interpolation has incomplete information along the edges. Prefer to manually expand all textures to power of 2 before loading. Use the desired color for those padding pixels.

If you have many small textures of arbitrary dimension it might also be a good idea to create a single power of 2 texture atlas.

\$\endgroup\$
1
  • \$\begingroup\$ most of my textures are power of 2 and still had the border.. I've since posting this question switched to vector based graphics, since I've seen issue after issue with textures in OpenGL with transparency. it ended up making more sense for my art style anyways. so thanks for the help, i'll just leave this question open in case anyone else has a similar issue. \$\endgroup\$
    – Dylan
    Nov 7, 2013 at 23:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .