0

I can't seem to get the transparent background on my image to load as transparent. It's always white instead. I'm still fairly new to OpenGL/SOIL so if I did something stupid don't be mad :/ Does it have to do with my flag on the load being RGB instead of RGBA?

void Scene::loadTexShips()
{
    texShips[0] = SOIL_load_OGL_texture(
        "Textures/Carrier.png",
        SOIL_LOAD_LA,
        SOIL_CREATE_NEW_ID,
        SOIL_FLAG_MIPMAPS | SOIL_FLAG_NTSC_SAFE_RGB
    );
    if (texShips[0] == 0)
    {
        printf("SOIL loading error: '%s'\n", SOIL_last_result());
    }
}

void Scene::drawShips()
{
    glColor4ub(255, 255, 255, 255);

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glLoadIdentity();              

    glTranslatef(6.0f, 2.0f, -12.0f);

    glBindTexture(GL_TEXTURE_2D, texShips[0]);

    glBegin(GL_QUADS);
    glTexCoord2f(0, 0);
    glVertex3f(-4.0f, -3.0f, 2.0);

    glTexCoord2f(0, 1);
    glVertex3f(-4.0f, -2.3, 2.0);

    glTexCoord2f(1, 1);
    glVertex3f(-1.0, -2.3, 2.0);

    glTexCoord2f(1, 0);
    glVertex3f(-1.0, -3.0, 2.0);
    glEnd();
    glDisable(GL_TEXTURE_2D);
}
  • Does your texture display correctly at all with this code? What kind of texture exactly are you trying to load? Can we see the texture and the a screenshot of the result? – Aiman Al-Eryani May 24 '16 at 19:08
  • Nevermind. I figured out the transparency was created incorrectly with the image. After re-creating the transparency, it works now. Thanks anyways! – Vincent Jenkins May 24 '16 at 20:12

0 Answers0