Advertisement

Automatically loading in BMPs

Started by April 04, 2002 03:44 AM
4 comments, last by Questionmark 22 years, 8 months ago
I''m new here, but I think you can expect to see me here more often now. Gamedev.net is great as fas as I can tell. I''m not a bloody newbie, I''ve written Pong with OpenGL (which was pretty cool by the way, but you couldn''t beat the computer... :D ) and I''m now into writing a little gallery. I already have a room with frames and everything. The whole architecture of the gallery is based upon the number of pictures. I want the program to automatically load in any bmp-file in a given folder, which will then be textures for the pictures. I don''t know how to get the names of the files though, and someone told me that this was basic c-stuff. I hope you can help! Thanks in advance
Not sure what you mean by "automatically". Nothing is done automatically

Well in Win32API there are functions called FindFirstFile() and FindNextFile() look them up.
-------------Ban KalvinB !
Advertisement
Look into the Win32 API functions FindFirstFile and FindNextFile.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
quote: Original post by granat
Not sure what you mean by "automatically". Nothing is done automatically


With automatically I meant that the user doesn''t have to do anything but putting the bmps into the folder.

I''ll look those things up, thanks for the fast responces.
Damn, I have to install that documentation now, looks like I didn''t want it when I installed VC++6...

I don''t understand.
I need a loop that saves the filenames the program finds in the folder in an array.
Another loop will then read in the first element of the array, and create a texture of the bmp-file.
The second loop is finished, but I have to enter the elements right now myself.
I''ve looked up the functions you mentioned on http://msdn.microsoft.com/library/default.asp?url=/workshop/management/tools/reference/ifaces/iwpsitew/findfirstfile.asp but I don''t understand that.
Just what is it, the FindFirstFile() takes up as arguments?
I think I could write the loop if I''d understand the FindFirstFile()/FindNextFile functions.

Sorry for bad grammar and/or spelling. I''m from Germany.
You really only need a single loop, just make sure OpenGL is intitialized and Texture_2D is enabled before running the loop, and generate the textures within the loop (so you don''t have to store anything!).


WIN32_FIND_DATA fd;
HANDLE hFind;

//Find only .bmp files!
hFind = FindFirstFile("C:/Directory/*.bmp",&FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
//Error searching, either Directory not found, or no files!
return;
}
//Go to our loop, and load our first texture.
do {
LoadTexture(fd.cFileName);
} while (FindNextFile(hFind, &fd)); //While more files exist.

FindClose(hFind); Close our search!


Billy - BillyB@mrsnj.com

This topic is closed to new replies.

Advertisement