Jump to content
  • Advertisement
Sign in to follow this  
Battagline

Screen Shot Dump

This topic is 4810 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 having trouble getting good combat screen shots from my game. The reason being that in the heat of battle, it's hard to hit ctrl-printscreen at the precise moment for a good screen shot. Someone suggested that I put something into my game that I can turn on or off that would periodically (a few times a second) write a screen print out to files in a folder. Then I could just go through the files afterward and pick out the good ones. The only problem with this idea is I have absolutely no idea how to do it. any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
You could use PIX, I think it can save images of frames being rendered in your application. Search google or MSDN.

Here is some code I used in VB6 to take screenshots. It may be a bit outdated, but should be adaptable.


'=================================================
'Takes a screenshot
'-------------------------------------------------
'Device what device to pull pixels from
'File path + file + extension
'Width image output width
'Height image output height
'-------------------------------------------------

Public Function ScreenShot(Device As Direct3DDevice8, File As String, Width As Integer, Height As Integer)

Dim FrontBuffer As Direct3DSurface8
Dim SRECT As RECT
Dim sPalette As PALETTEENTRY

With SRECT
.Left = 0
.Right = Width
.Top = 0
.Bottom = Height
End With

On Error GoTo Release:

Set FrontBuffer = Device.CreateImageSurface(Width, Height, D3DFMT_A8R8G8B8)
Device.GetFrontBuffer FrontBuffer

D3DX.SaveSurfaceToFile File, D3DXIFF_BMP, FrontBuffer, sPalette, SRECT

Release:

Set FrontBuffer = Nothing

End Function

Share this post


Link to post
Share on other sites
The only thing that you've got to do is to implement a ScreenShot() function/method for taking screenshots and then creating another function/method which checks a var if its true or false which indicates if screenshots should be taken continuesly during playing. As soon as you want to take screenshots you set the var to true by pressing a button or whatever ... the next thing you'll need is to count time so you just call the take screenfunction every 3 secs or whatever

so a pseudoexample would be:

static bool bshoot; //set default to false
static float fTimePassed; //(in sec) default to 0.0

void Screenshot(void){
//blah source for saving a screenshot
}

void Screenshooter(void){
if((bshoot == true) && (fTimePassed == 3.0))
{
Screenshot();
fTimePassed == 0.0;
}
}

RefreshTime(); //-->well just think what this could be for


This is just a fast description of how I'd try to do this.

Hope I could help

cheer,
Marcel

Share this post


Link to post
Share on other sites
Another options is to use a tool like Fraps which can also record a movie of your game which can be handy for marketing. Screenshots are nice to look at but really don't tell you how a game plays.

Share this post


Link to post
Share on other sites
Quote:
Original post by Battagline
... Someone suggested that I put something ...

Hmm, I wonder who that someone might have been. Oh well, I guess we'll never know for sure.

My idea is very similar to MMarcel's, only with a count-down instead of a count-up - this is beacause it is much cleaner to test against 0.0 than the time limit, and because if the time limit is changed during counting the count-down will not end up with a strange interval.

Trigger the screenshot flag on a keypress, and set the counter to the time limit.

As I said, vrey similar... I'll be quiet now.

Share this post


Link to post
Share on other sites
The above algorithms are pretty much on the nose of a way to do this. As your using DX, you can very easily capture the screen using the D3DX functions.

The following code just shows how to use the D3DXSaveSurfaceToFile function


// Get the current back buffer
hr = dxSettings.d3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &d3dSurface);

// Save the backbuffer to a file
hr = D3DXSaveSurfaceToFile(imageFileName, D3DXIFF_BMP, d3dSurface, NULL, NULL);


ImageFileName is the name of the file that will be created with the image.

The D3DXIFF_BMP is the format the screen is saved at. There are various types, including JPEG, the type obviously relates to the size of the final image.

d3dSurface is the surface that will be transfered to the file.

It probably takes about a 10th of second to capture the screen, so you will have a slightly noticable pause when your playing the game, especially if you are capturing the screen every second.

As your capturing the back buffer in the above example, you would call it just before you flip the buffers, so that you have a complete image.

Hope that helps

Spree

Share this post


Link to post
Share on other sites
This would be a whole implementation of the thing. I use it like this except that I've got some things defined as members of a class, but that's not important for you.

Screenshot(void){
static Rect rcRect;
static LPDIRECT3DSURFACE9 lpD3DSurf;

yourD3DDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &lpD3DSurf);

rcRect.left = 0;
rcRect.top = 0;
rcRect.right = yourScreenWidth;
rcRect.bottom = yourScreenHeight;

static char file[128];
static int c = 1;
sprintf(file, "Screenshot%i.jpg", c++);

D3DXSaveSurfaceToFile(file, D3DXIFF_JPG , lpD3DSurf, NULL, &rcRect);
}

By changing the rcRect.left, right, top or bottom vars you can capture also just particular parts of the screen.

The little part with char sprintf stuff is just for creating multiple files with a number attached.

cheers,
Marcel

Share this post


Link to post
Share on other sites
Just a note, but you'll probably want to override the timer. If you're printing out the screen to file, it's going to take time. I just forced the time to always remain at 33 milliseconds per frame while holding the print key. It will ensure that your movie output has an exact frame rate, plus avoids playing with extremely choppy movement as you record. Might become a problem if your PC or hard drive is extremely fast, as your game will speed up to match the frame rate.

Share this post


Link to post
Share on other sites
Quote:
Original post by staaf
Hmm, I wonder who that someone might have been. Oh well, I guess we'll never know for sure.


[wink]

ok credit where credit is due. Thanks for the idea staaf. Now I just need to figure out how to do it. I'll play with the suggestions here. I'm a bit slow so it may take a while.

Thanks everyone and I'm sorry if I've short changed anyone else [smile]

[Edited by - Battagline on July 27, 2005 11:56:34 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!