File list from Directory
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]
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.
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.
FindFirstFile
FindNextFile
FindClose
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
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.
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.
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement