Sign in to follow this  
Lifepower

GetFrontBufferData() doesn't work with multiple monitors?

Recommended Posts

Lifepower    136
Hello, I am trying to take screenshots using GetFrontBufferData() method of IDirect3DDevice9 in windowed mode. As manual states:
Quote:
For windowed mode, the size of the destination surface should be the size of the desktop.
Okay, my desktop size is 2560x1024 because of two 1280x1024 monitors. I create the surface with that size and call GetFrontBufferData(). It seems to work properly, but only the area of primary monitor is captured, the other one is just black. That is, if I save the entire front buffer data captured with the above method, the right half of the image is just black. If I move application window from primary monitor to secondary one, there is no way of taking screenshot since this area is not captured. I am wondering if this is a driver problem or GetFrontBufferData() only works for the area of primary monitor?

Share this post


Link to post
Share on other sites
streamer    415
My code of screenshot taking procedure (I think it works with two monitors too):



HRESULT makeScreenshot()
{
IDirect3DSurface9 *pScreenshot = NULL;
static int g_uNumScreenshots = 0;

m_pd3dDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pScreenshot );

TCHAR szScreenshot[32];
sprintf( szScreenshot, "ScreenShot%.2d.jpg", g_uNumScreenshots++ );
if(FAILED(D3DXSaveSurfaceToFile( szScreenshot, 1, pScreenshot, NULL, NULL )))
{
return E_FAIL;
}

SAFE_RELEASE( pScreenshot );

return S_OK;

}

Share this post


Link to post
Share on other sites
Lifepower    136
Streamer, unfortunately, your approach only gives me colored filled screens. Shouldn't be the back-buffer lockable for your method to work? (mine isn't)

Anyone had experience with GetFrontBufferData() on multi-monitor setup?

Share this post


Link to post
Share on other sites
Evil Steve    2017
You need to call streamer's function before calling Present(), but after EndScene(). Otherwise the front and backbuffer have been flipped, and the debug runtime will fill the new backbuffer with magenta or green (Which is what you're seeing) if you use D3DSWAPEFFECT_DISCARD (Which you should be doing).

Also, streamer's function should really free the backbuffer pointer even if D3DXSaveSurfaceToFile() fails.

It doesn't seem to require a lockable backbuffer - my backbuffer isn't lockable and it works for me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this