How to get ScreenShot of a game Window
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
That should still work - GetFrontBuffer in windowed mode should just get you the windowed area.
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
samreen
http://gamedev.net/reference/programming/features/sshot/
Here you go.. how to design a screenshot system from the ground up
Here you go.. how to design a screenshot system from the ground up
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
//////////////////////////////////////////////////////////////
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement