Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

samreen

How to get ScreenShot of a game Window

This topic is 5220 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

hi all, i want to take screenshot of only the game window. i chked the article of GameDev.net tht captures Screenshot of full desktop using GetFrontBuffer().But i want to get only the screen shot of game window (game is running in windowed mode). thanx Samreen

Share this post


Link to post
Share on other sites
Advertisement
That should still work - GetFrontBuffer in windowed mode should just get you the windowed area.

Share this post


Link to post
Share on other sites
thx, actually i m taking screenshot from DirectX wrapper, using the same code as in GameDev article. does its behaviour will be same as taking screenshot from within game?

samreen

Share this post


Link to post
Share on other sites
http://gamedev.net/reference/programming/features/sshot/

Here you go.. how to design a screenshot system from the ground up

Share this post


Link to post
Share on other sites
The above refferd article captures screenshot of the game window having it HWND. The place from where i want to capture game window doesnt give its HWND. Instead i m using GetFronBuffer() to get data. the problem is that i got full screen not the specific window region. below is the code

//////////////////////////////////////////////////////////////
int Height=0, Width=0;

// We need to know for which adapter the Direct3D device was created,
// so that we can query the right adapter''s screen dimensions.
// Therefore, query the device''s creation parameters
D3DDEVICE_CREATION_PARAMETERS dcp;
dcp.AdapterOrdinal = D3DADAPTER_DEFAULT;
lpDevice->GetCreationParameters(&dcp);

D3DDISPLAYMODE dm;
dm.Width = dm.Height = 0;

// retrieve pointer to IDirect3D8 interface,
// which provides the GetAdapterDisplayMode method
lpDevice->GetDirect3D(&lpD3D);

if (lpD3D)
{
// query the screen dimensions of the current adapter
lpD3D->GetAdapterDisplayMode(dcp.AdapterOrdinal, &dm);
SAFERELEASE(lpD3D);
}

Width = dm.Width;
Height = dm.Height;


/*D3DVIEWPORT9 pViewport;
HRESULT hr = lpDevice->GetViewport(&pViewport);
if(hr == D3D_OK)
hr=hr;

//Height = 600;//pViewport.Height;
//Width = 800;//pViewport.Width;*/

if (FAILED(
lpDevice->CreateOffscreenPlainSurface(Width, Height,
D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH,
&lpSurface, NULL)
))
{
throw runtime_error("Function \"Screenshot\": "
"IDirect3DDevice9::CreateImageSurface failed.");
}

// have the GetFrontBuffer method copy the contents of the front
// buffer to our system-memory surface

if (FAILED(lpDevice->GetFrontBufferData(0,lpSurface)))
{
throw runtime_error("Function \"Screenshot\": "
"IDirect3DDevice9::GetFrontBuffer failed.");
}

//////////////////////////////////////////////////////////////

here i m creating surface according to the display''s height & width. if i change the values it cause crashing.

anyone know what is wrong?

thx
samreen

Share this post


Link to post
Share on other sites

  • 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!