Jump to content
  • Advertisement
Sign in to follow this  

generating screenshot file names

This topic is 4423 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

I'm writting a game in C++/oGL, I need to be able to take screenshots. The actual writting the .bmp file is np, but I have no clue how to do the Screenshot0001.bmp Screenshot0002.bmp Screenshot0003.bmp Screenshot0004.bmp.... Rather than just keep a list I want to be able to something like "GetListOfFileIesFolder("Screens");" Is there a way to do that in C++?

Share this post

Link to post
Share on other sites
Here's an example of how to list files in a directory. After you've done this, you can parse the filenames and create a new filename based on that information. (Windows)

Share this post

Link to post
Share on other sites
You can just do something like this if you don't want to rely on operating system libraries:

int num = 1;
string name = "Screenshot";
string extension = ".bmp";
//find the next available filename
string fileName;
fileName = name + num + extension;
fstream file(fileName.c_str(), ios::in);
//no need to close the file, it will be done automagically
//good, now we can open it and actually use it
fstream file(fileName, ios::out | ios::binary);

EDIT: I was being fast and loose, you cant actually do fileName = name + num + extension; Consider it as pseudo-code :-)

[Edited by - deathkrush on June 12, 2006 3:00:17 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!