Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hey guys, i'm a total newb to d3d, but I'm hoping what I am asking is fairly simple.

 

I have a c# application, I have referenced the required DirectX dll's.

 

I now have a video game running, in D3D.

 

I want the c# application to take a screen shot of what I see in-game.

 

This is what I have so far, and I'm kind of lost. Can anyone help me?

 

 

IntPtr hWnd = new IntPtr();

 

foreach (AdapterInformation adapter in Manager.Adapters)

{

// Check whether or not this is the default adapter

if (adapter.Equals(Manager.Adapters.Default))

{

hWnd = Manager.GetAdapterMonitor(adapter.Adapter);

}

}

 

if (hWnd != null)

{

Device device = new Device(hWnd);

 

try

{

Surface renderTarget = device.GetBackBuffer(0, 0, BackBufferType.Mono);

SurfaceLoader.SaveToStream(ImageFileFormat.Jpg, renderTarget);

}

catch (AccessViolationException avex)

{

avex.Data.Clear();

}

}

 

 

 

My code is obviously flawed, however, I'm not good with this d3d stuff. I realize I am CREATING a new device, which I do not want to do. How do I access the existing application(game) device, and then take a screen shot of it?

 

Thanks!

 

Steve

Edited by v8maro

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...