File list from Directory

Started by
3 comments, last by TheBlackJester 22 years, 1 month ago
Hey, In modern 3D Games, there is usually a need to load a large amount of textures at a time. This is my problem: If I''m loading 20+ textures for a scene, doing this 20 times will be very inefficient... tex_Texture.Load("data/textures/myTexture.tga"); So, what I would like to know is this. Is there a way to get a list of files from a directory (in this case "data/textures") and load them all? Thanx ''I sure could use a vacation from this bullshit three ring circus sideshow of freaks...'' - TOOL [TheBlackJester]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

Advertisement
one of the techniques i can think of is, have the names of all the texture files u wanna load in another file (call it load.tex). so whenever u want to load all the texture files, just open the load.text file and get the file name u wanna load and load it.. u''ll just use a small while loop something like this..

fp = fopen("load.tex","w");
while((fread(vlStr,32,1,fp)) > 0)
{
/* Note vlStr has the file name of the texture file you want to load. */
LoadTexture(vlStr); /* use the appropriate function */
}

i am not sure if this is an efficient technique, but this is better than using 20 loadtexture statements for each of the 20 texture files. i hope i made sense

Slow and steady wins the race.
Slow and steady wins the race.
FindFirstFile
FindNextFile
FindClose

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
FindFirstFile
FindNextFile
FindClose

---> is a good technique too, if all the textures you want to load are in the same directory.. but if u have textures in various directories or if u want to load only a few textures from a directory, probably my method would work fine.

Slow and steady wins the race.
Slow and steady wins the race.
Hey thanx,

Yeah, all the files are gonna be in the same directory


''I sure could use a vacation from this bullshit three ring circus sideshow of freaks...'' - TOOL
[TheBlackJester]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

This topic is closed to new replies.

Advertisement