• Advertisement

Archived

This topic is now archived and is closed to further replies.

File list from Directory

This topic is 5814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement