Black or White Border/Shadow around PNGs in SDL/OPENGL
Posted
by
Dylan
on Game Development
See other posts from Game Development
or by Dylan
Published on 2013-11-03T21:18:01Z
Indexed on
2013/11/03
22:19 UTC
Read the original article
Hit count: 251
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, and messes with my background color and some polygons I'm drawing (not all of them weirdly) by making them much lighter...
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);
© Game Development or respective owner