0

right now I'm trying to load a Image texture for a quad using DevIL image Library, I'm having a problem that no matter whats path I specify or type of image I tell it to load, it will always tell me error code 1290, which is IL_COULD_NOT_OPEN_FILE, could anyone help?

Code to load:

bool imageLoaded = false;

    auto mIt = m_textureMap->find(filePath);
    if (mIt == m_textureMap->end())
    {
        Texture temp;

        glGenTextures(1, &temp.id);

        glBindTexture(GL_ARRAY_BUFFER, temp.id);

        if (ilLoad(IL_PNG, (const wchar_t*)filePath.c_str()))
        {
            if (ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE))
            {                           

                temp.width = ilGetInteger(IL_IMAGE_WIDTH);
                temp.height = ilGetInteger(IL_IMAGE_HEIGHT);


                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, temp.width, temp.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ilGetData());


                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_MAG_FILTER, GL_LINEAR);

                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

                glGenerateMipmap(GL_TEXTURE_2D);

                m_textureMap->insert(make_pair(filePath,  temp));

                imageLoaded = true;
            }
        }

        glBindTexture(GL_ARRAY_BUFFER, 0);
    }
    else
    {
        imageLoaded = true;
    }

    ILenum error = ilGetError();
    if (error != IL_NO_ERROR)
    {
        printf_s("Error %d\n", error);
    }

    return imageLoaded;

The filePath is: "Textures/platformer_sprites.png" and it's a std::string

and the location in my PC of the file is: "D:/Desarrollo/C++/Project SOP\BaseSurvivor/BaseSurvivor/Textures/platformer_sprites.png"

Any help is appreciated and sorry for my bad English.

4

0 回答 0