Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am trying to write a simple application that takes screenshots from games environment. I've search and based on my searches I need to use DirecX backbuffer. I tried to write some code, it works fine using frontbuffer that takes desktop screenshots, but when I use backbuffer and start a game to take pictures, it gives an error from Device() function saying : "Error in the application". How can I take screenshots from a game? what is wrong with this code?
Thanks.

Code:
PresentParameters pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
Device device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, pp);
Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.Save("1.bmp", ImageFileFormat.Bmp, backbuffer);
Posted
Updated 13-Sep-12 0:28am
v3

1 solution

 
Share this answer
 
Comments
mehdi_k 14-Sep-12 3:48am    
thanks, but that article is about front buffer that is not my problem, the front buffer take screenshots like print screen, but I want to take screenshots from games.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900