GetFrontBufferData() doesn't work with multiple monitors?

Started by
3 comments, last by Evil Steve 16 years, 9 months ago
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?
Advertisement
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;}
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?
I don't know...On my PC it works perfectly....[sad]
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.

This topic is closed to new replies.

Advertisement