Hi guys,
I’m trying to load textures with DevIL and, but some reason, it’s not working. Let me explain the problem.
First of all, I have an object with X meshes. I read it from “…/assets/FerrariCalifornia/California/california.obj”. In the same folder, I have a few .tga files that I need to load as textures. This is how I’m loading the files:
For every mesh of the object:
aiString texturePath;
const char *materialTexture;
unsigned char *textura;
ILstring texturita;
if (AI_SUCCESS == material->GetTexture(aiTextureType_DIFFUSE, 0, &texturePath))
{
materialTexture = texturePath.C_Str();
texturita = ((ILstring)materialTexture);
}
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
//Image with DevIL
ilGenImages(1, &textureId);
//Bind
ilBindImage(textureId);
//Load the image
ILboolean success = ilLoadImage(texturita);
ILenum Error;
while ((Error = ilGetError()) != IL_NO_ERROR) {
printf("%d: %s/n", Error, iluErrorString(Error));
}
//Check to see if everything went OK
if (!success) {
ilDeleteImages(1, &textureId);
}
else {
printf("PERFECT!
");
}
As you can see, I’m just trying to load the textures, nothing else. The problem is that it prints “PERFECT” during the first loop, but it’s not working for the next loops. The following error appears:
[b]1290: could not open file[/b]
And sometimes, this one:
[b]1289: invalid parameter[/b]
Do you know why is this happening? I don’t understand why it works for the first file and not for the other ones.
In case you are wondering, this is how I initialise DevIL:
/* ----- Initialise DevIL -----*/
// Initialize IL
ilInit();
// Initialize ILU
iluInit();
// Initialize ILUT with OpenGL support.
ilutRenderer(ILUT_OPENGL);
Thank you in advance for your help!