0

I am now trying to create a screen capture program. Last week I have tried the GetFrontBufferData method and it succeed. However, its performance is terrible and can only catch the desktop images. It means that when I start to run a full screen game, the GetFrontBufferData Method will get nothing. But what I want is to catch the full screen game not the desktop images.

In the GetFrontBufferData solution, I created a device and let the HWND parameter be NULL. I wonder if I can get the handle of the toplevel window (mean, the handle of full screen game), and pass it to the CreateDevice method, I can catch its screen shot.

Actually I have tried several screen capture method based on DX9. I have studied the questions Fastest method of screen capturing and tried the GetRenderTarget() method in conjunction with GetRenderTargetData(). The problem is I can only get the Render data rendered by the program itself. And the same with GetBackBuffer().

So the problem comes to, can I get a specific window image (like some running full screen game) if I can get the Handle of the toplevel window? I have checked the EnumWindow method described in Win32 - Get Main Wnd Handle of application. This code seems to get windows which only created by the program it self according to my test. However I need to get some windows created by the other programs.

So, that is my question. In a word, I want to know two things: 1, Is my approach that get handles of other windows then pass it to the CreateDevice and get its screen shot right? 2, If it is right, how to get the handles; if it is wrong, what is the rigth way to capture the full screen games?

Community
  • 1
  • 1
XLinC
  • 23
  • 5

1 Answers1

0
  1. That's not right, the window handle passed to CreateDevice has nothing to do with screen capture, it is the window that alert Direct3D when the app go background. since you want to capture the screen data stream from another app, so the window handle here cannot help you.

  2. Since performance is critical, and GetFrontBufferData was time-consuming, so the only way I think suit for your need is Hooking Direct3D, interrupt the call to Present, and get the data from backbuffer, then you can do what you want, this is just an idea, I am not familiar with hooking and I never hooking Direc3D before.

Here is something about the two window handle used in CreateDevice(from DirectX SDK document)

When you create a Direct3D device, you supply two different window parameters: a focus window (hFocusWindow) and a device window (the hDeviceWindow in D3DPRESENT_PARAMETERS). The purpose of each window is: The focus window alerts Direct3D when an application switches from foreground mode to background mode (via Alt-Tab, a mouse click, or some other method). A single focus window is shared by each device created by an application. The device window determines the location and size of the back buffer on screen. This is used by Direct3D when the back buffer contents are copied to the front buffer during

Present.

zdd
  • 8,258
  • 8
  • 46
  • 75