Jump to content
  • Advertisement
Sign in to follow this  
Lifepower

GetFrontBufferData() doesn't work with multiple monitors?

This topic is 4026 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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;

}

Share this post


Link to post
Share on other sites
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!