Can't 'print screen' in my app

Started by
3 comments, last by circlesoft 19 years, 1 month ago
Hi, I am using C++ and Direct3D9. In my app I used to be able to press 'print screen' and then quit out of the app and paste the screenshot into paint. Now all I get when I try print screen is a screenshot that is entirely green. Anyone got any ideas why it would do this? Is it something to do with my 2d ortho matrix ( D3DXMatrixOrthoOffCenterLH )?

HTML5, iOS and Android Game Development using Corona SDK and moai SDK

Advertisement
Since the window bound to the d3d device is drawn using hardware acceleration, there's no guarantee that the final rendered image is accessible to GDI at all. Matrices have nothing to do with this problem.

If you want to take a snapshot of the current d3d frame, see IDirect3DDevice9::GetFrontBufferData().

Niko Suni

void takeScreenShot(LPCTSTR pDestFile){  D3DDISPLAYMODE displayMode;   LPDIRECT3DSURFACE9 pd3dsFront = NULL;   // Get the display mode  pd3dDevice->GetDisplayMode(0, &displayMode);   // Create a surface to hold the front buffer  pd3dDevice->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height,    D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pd3dsFront, NULL);   // Get the front buffer and save it to a file  if( SUCCEEDED( pd3dDevice->GetFrontBufferData(0, pd3dsFront) ) )    D3DXSaveSurfaceToFile(pDestFile, D3DXIFF_BMP, pd3dsFront, NULL, NULL);   // Release the surface  if( pd3dsFront ) pd3dsFront->Release();}
It can be done without using GetFrontBufferData too. This will work with Direct3D and OpenGL. The only Direct3D code used is SetTransform for the high resolution screen shots.

|
|
|
V
Here is the really simple code I use:

LPDIRECT3DSURFACE9 pSurf;pd3dDevice->GetRenderTarget( 0, &pSurf );D3DXSaveSurfaceToFile( L"screenshot.bmp", D3DXIFF_BMP, pSurf, NULL, NULL );pSurf->Release();
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )

This topic is closed to new replies.

Advertisement