Small black outline around image OpenGL

Viewed 56

I have this image: sprite

I'm loading a texture (.png file) into my viewport I'm using

// enable blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

to get rid of the black alpha channel, however the problem is that there is still a small black line around the sprite, i'm not sure if it's visible in the image or not. Here's the code I use for my textures:

// generate and bind the texture
unsigned int texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);

// configure the texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

// flip the image vertically so texture isn't upside down
stbi_set_flip_vertically_on_load(true);

// load an image while getting the width, height, and number of color channels
int width, height, nrChannels;
unsigned char* data = stbi_load(imageFile, &width, &height, &nrChannels, 0);

// if we have the image
if (data)
{
    // create texture and mipmap for the texture
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
    glGenerateMipmap(GL_TEXTURE_2D);
}
else // we don't have the image
{
    // print
    std::cout << "Failed to load texture" << std::endl;
}
// free the image data and delete it
stbi_image_free(data);
1 Answers

Thanks, @Scheff's Cat, for your help. I guess it was just the way it's supposed to appear, it does look like it has a black line and I put it into some other programs and it did the same thing. It's just how it is supposed to appear most sprites that have more detail shouldn't appear that way.

Related