Original Post
i was holding off on posting this because i thought i had an older version that worked, but it turns out that too has the same issue. description of the problem: i have a working .3ds loader. it takes in the model data correctly and places it into my storage object correctly. i also thought i had a working texture loading method. i say thought because up until today it worked just fine, and now it doesn't. i have one file that only has one texture to load and it works fine. i have another file that loads 4 textures and that now breaks. previously it had worked. the program also breaks when i try files with 6 and 8. it is apparently breaking after loading the 2nd texture. the only difference between the previously working method and this is ... nothing. absolutely nothing changed for the code that loads textures. the only difference between the two total projects is in the most recent i changed a struct to a class, but that data type is never used by the texture loading algorithm or even in the data that holds the overall .3ds info. the reason i say the string variables are disappearing is because the values within the variables becomes nothing, even going so far as to cause a seg fault which even means they are pointing to data that doesn't belong to them. however, this doesn't make sense because prior to trying to load the actual image files into memory i can get those string values (which are the material name and the texture filename). i have tried using insight to get the values while in that for loop, but to no avail. does anyone have any idea what might be happening? i'm totally at a loss. thanks! [Edited by - supercat1 on July 28, 2006 10:53:56 PM]
for(int i = 0; i < testobj.nummaterials; i++)
{
cout << "i = " << i << endl;
testobj.materials.materialtexture.textureidnum = -1;
if(testobj.materials.materialtexture.filename.size() > 0)
{
cout << "materialtexture name: " << testobj.materials.materialtexture.filename << endl;
ilGenImages(1, &ImageName);
ilBindImage(ImageName);
if(ilLoadImage(const_cast<char*> (testobj.materials.materialtexture.filename.c_str())) == IL_FALSE)
{
cout << "unable to open: " << testobj.materials.materialtexture.filename << endl;
}
else
{
// cout << "i = " << i << "\ttextobj.materials.texture.texturidnum = " << testobj.materials.texture.textureidnum << endl;
cout << "able to load: " << testobj.materials.materialtexture.filename << endl;
testobj.materials.materialtexture.textureidnum = ilutGLBindTexImage();
testobj.materials.materialtexture.texwidth = ilGetInteger(IL_IMAGE_WIDTH);
testobj.materials.materialtexture.texheight = ilGetInteger(IL_IMAGE_HEIGHT);
testobj.materials.materialtexture.data = ilGetData();
glBindTexture(GL_TEXTURE_2D, testobj.materials.materialtexture.textureidnum);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, testobj.materials.materialtexture.texwidth, testobj.materials.materialtexture.texheight, GL_RGB8, GL_UNSIGNED_BYTE, testobj.materials.materialtexture.data);
}
ilDeleteImages(1, &ImageName);
cin >> a;
}
}