
Help with loading multiple Textures from a file
I am having trouble getting multiple textures to load. I have a variable called
char *TextureList[20];
This will hold the texture file locations read from a file in the textures folder. So, i put the load texture code in a loop like this
int LoadGLTextures()
{
int Status=FALSE;
int tLoop=0;
AUX_RGBImageRec *TextureImage[4];
memset(TextureImage,0,sizeof(void *)*4);
TextureImage[0]=LoadBMP("Textures/Font.bmp");
for(tLoop=1;tLoopsizeX, TextureImage[tLoop]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[tLoop]->data);
tLoop+=1;
}
tLoop=0;
while(tLoopdata)
{
free(TextureImage[tLoop]->data);
}
free(TextureImage[tLoop]);
}
tLoop+=1;
}
return Status;
}
Some editing had to be done to get it to fit in this small window, but you get the idea, this is the exact code i have. Now, MaxTextures is how many textures will be used and it is read from the texture list file. So, why do i always get an initialization error? The prob is i cant get
LoadBMP(TextureList[tLoop])
to work. It will read "Textures/texture.bmp" ok, but the same string in the TextureList[] variable, it wont take it. y? Please help me i''m getting frustrated

Dustin DavisOwner / CEOProgrammers Unlimitedwww.Programmers-Unlimited.com
Oops, forgot to mention that i will also, be loading font.bmp into textures[0] by default, so i will have MaxTextures+1
Also, looks like the forum cut off some of my loop code
But the rest of the for and while loops are here in my code, just cut off in the post.
Also, looks like the forum cut off some of my loop code

Dustin DavisOwner / CEOProgrammers Unlimitedwww.Programmers-Unlimited.com
first off, you would either have to give a reference of the texture array or a pointer. but probably not the problem.
why not do something like this:
char* NameList[] = {"Texures/Font.bmp",....};
then you have the array you can run through.
if course you texture array has to have the same size.
hope i could help.
why not do something like this:
char* NameList[] = {"Texures/Font.bmp",....};
then you have the array you can run through.
if course you texture array has to have the same size.
hope i could help.
I am reading the textures used from a file.
ifstream fin("level1.tx");
fin >> texturelist[loop];
i do it like this.
char *Texturelist[20]; //this is what its defined as
ifstream fin("level1.tx");
fin >> texturelist[loop];
i do it like this.
char *Texturelist[20]; //this is what its defined as
Dustin DavisOwner / CEOProgrammers Unlimitedwww.Programmers-Unlimited.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement