Jump to content

Take Screenshots


Qbound
 Share

Recommended Posts

Hi Werker's,

 

if you want to take screenshots you can use the SaveBuffer() function on the Backbuffer(), thats an easy way.

 

But what about the naming?

 

My Game NightFist is slowly growing and i want to document my progress with screenshots.

Therefore i took a few minutes to find an easy solution to create good names.

 

Here is my way

#include <time.h>
#include <string>

 

// Take Screenshot?
if( KeyHit( KEY_F12 ) )
{
//
// Create the name and save it (using the format 'NightFist_2009_12_06-13_59_42.jpg'
//

// Variablen init
time_t	mTime = time( NULL );												// Time
tm	*mDate = localtime( &mTime );											// DateTime Structure
char	cBuf[40];													// copy Buffer

// Now Create the TimeStamp for the file
sprintf( cBuf, "%4d_%2d_%2d-%2d_%2d_%2d", mDate->tm_year + 1900, mDate->tm_mon + 1, mDate->tm_mday, mDate->tm_hour, mDate->tm_min, mDate->tm_sec );

// Start with the Prefix
std::string strName = "NightFist_";

// Then the Timestamp
strName += cBuf;

// and the ending
strName += ".jpg";

// Save Buffer
SaveBuffer( BackBuffer(), (str)strName.c_str(), 85 );
}

 

have fun and let us see your screenshots :)

 

cu

Oliver

  • Upvote 1

Windows Vista 64 / Win7 64 | 12GB DDR3 1600 | I7 965 | 2 * 280GTX sli | 2 * 300GB Raptor | 2 * 1.5TB

Link to comment
Share on other sites

Ah thanks for the tipp Aggror, there is the string include and the namespace missing.

 

i have updated the code. this should work.

 

cu

Oliver

Windows Vista 64 / Win7 64 | 12GB DDR3 1600 | I7 965 | 2 * 280GTX sli | 2 * 300GB Raptor | 2 * 1.5TB

Link to comment
Share on other sites

This looks very good!

 

I have an error though:

 

it says that 'string' is an undeclared identifier, which is weird because it's a data type.

 

It's probably because you haven't included using std namespace; before using the string data type, or you should use std::string in place of string. Either option will get you the same results, but the latter does not require using std namespace be defined first.

Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5.

Link to comment
Share on other sites

  • 2 weeks later...

There is no command called CurrentBuffer(), I think you meant BackBuffer().

Then your command should be:

SaveBuffer( GetColorBuffer(BackBuffer(),0), (str)strName.c_str(), 99 );

  • Upvote 1

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

I had something similar to this working in earlier version of LE, but now all I get is a black image.

 

Here is some code:

 

SaveBuffer(BackBuffer(),filename, 100);
strcpy(g_strScreenshot, filename);
g_bScreenshotMsg = true;
sprintf(temp, "Saved screenshot as: %s", g_strScreenshot);
AppLog(temp, 0);
done=true;

 

I am using Framewerk and LE 2.28, do I need to pass a buffer from Framewerk or is using BackBuffer still fine?

Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...