我似乎无法将图像上的透明背景加载为透明。 它总是白色的。 我对OpenGL / SOIL还是很陌生,所以如果我做了一些愚蠢的事情,请不要生气:/这是否与我的负载标志是RGB而不是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);
}

  ask by Vincent Jenkins translate from so

本文未有回复,本站智能推荐: