Loading model Texture with DevIL

291 views Asked by At

I am using DevIL library to load textures to apply to models. This is the code I have written to load the texture into a texture buffer:

ILboolean success;
ILuint imageID;

glGenTextures(1,&_textureID);
glBindTexture(GL_TEXTURE_2D,_textureID);

ilGenImages(1,&imageID);
ilBindImage(imageID);

success = ilLoadImage((const ILstring)_fileName.c_str());

if(success){
    success = ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE);
    if(!success)
    {
        std::cout << "Could not convert image :: " << _fileName << std::endl;
        ilDeleteImages(1,&imageID);
        return false;
    }
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D,0,ilGetInteger(IL_IMAGE_BPP),ilGetInteger(IL_IMAGE_WIDTH),
        ilGetInteger(IL_IMAGE_HEIGHT),0,ilGetInteger(IL_IMAGE_FORMAT),GL_UNSIGNED_BYTE,
        ilGetData());


glBindTexture(GL_TEXTURE_2D,0);

When I render the scene, I get the following results:

enter image description here

I should also mention that assimp was used to load the model.Using assimp viewer, I get the results shown below.
enter image description here

I would like to know if there is something wrong with my code which cause the texture to be a dull grey.

0

There are 0 answers