Capture the screenshot!

Started by
16 comments, last by Jan Birsa 15 years, 2 months ago
I am trying to make a screenshot in C++ DX9 using DXUT, but I have some problems. I have fixed one already. The device didn't work as it should, I fixed that, and now device isn't NULL anymore. It makes screenshot, but the problem is, its black. I get something.bmp, but its black, which is another frustrating problem I have. I guess there is something wrong with surface... Here is the code: HRESULT WINAPI CaptureScreen(IDirect3DDevice9* pd3dDevice) { IDirect3DSurface9* pSurface; //IDirect3DDevice9 *pd3dDevice = DXUTGetD3D9Device(); if (pd3dDevice != NULL) { //DXUTShutdown( 0 ); //proof device isnt NULL pd3dDevice->CreateOffscreenPlainSurface(1024, 768, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pSurface, NULL); pd3dDevice->GetFrontBufferData(0, pSurface); } D3DXSaveSurfaceToFile(L"Media\\Screenshots\\something.bmp",D3DXIFF_BMP,pSurface,NULL,NULL); pSurface->Release(); return 0; } What should I do? Whats the problem?
Advertisement
If you want you can just call IDirect3DDevice9::GetBackBuffer and pass that surface to D3DXSaveSurfaceToFile.
Quote:Original post by Jan Birsa
What should I do? Whats the problem?
What do the Debug Runtimes tell you the problem is?
I am pretty sre that the surface needs to be created in system memory pool and not in the scratch pool.
Quote:Original post by Demirug
I am pretty sre that the surface needs to be created in system memory pool and not in the scratch pool.

SYSTEMMEM pool didnt make any difference...
Quote:Original post by Jan Birsa
Quote:Original post by Demirug
I am pretty sre that the surface needs to be created in system memory pool and not in the scratch pool.

SYSTEMMEM pool didnt make any difference...
And what did the debug runtimes say when you used the system memory pool?
Quote:Original post by Evil Steve
Quote:Original post by Jan Birsa
Quote:Original post by Demirug
I am pretty sre that the surface needs to be created in system memory pool and not in the scratch pool.

SYSTEMMEM pool didnt make any difference...
And what did the debug runtimes say when you used the system memory pool?


When I run debug with breakpoints set I get here:
pd3dDevice->GetFrontBufferData(0, pSurface); red marked 0x04915500 on d3dx9.lib and 0x049c5600 on d3dx9d.lib. I have set debug on max in DX Cpanel for this run.



Quote:Original post by Jan Birsa
When I run debug with breakpoints set I get here:
pd3dDevice->GetFrontBufferData(0, pSurface); red marked 0x04915500 on d3dx9.lib and 0x049c5600 on d3dx9d.lib. I have set debug on max in DX Cpanel for this run.
Don't use any breakpoints on the DirectX control panel, just let the code run (and render black), and look at the debug output.

Even with "break on D3D error" enabled, you should still get some debug output.
Quote:Original post by Jan Birsa
Quote:Original post by Evil Steve
Quote:Original post by Jan Birsa
Quote:Original post by Demirug
I am pretty sre that the surface needs to be created in system memory pool and not in the scratch pool.

SYSTEMMEM pool didnt make any difference...
And what did the debug runtimes say when you used the system memory pool?


When I run debug with breakpoints set I get here:
pd3dDevice->GetFrontBufferData(0, pSurface); red marked 0x04915500 on d3dx9.lib and 0x049c5600 on d3dx9d.lib. I have set debug on max in DX Cpanel for this run.


What am I doing wrong?
Quote:Original post by Jan Birsa
Quote:Original post by Jan Birsa
When I run debug with breakpoints set I get here:
pd3dDevice->GetFrontBufferData(0, pSurface); red marked 0x04915500 on d3dx9.lib and 0x049c5600 on d3dx9d.lib. I have set debug on max in DX Cpanel for this run.


What am I doing wrong?
You're not looking at the debug output window. Can you paste the entire contents of the debug output window here when you get to that line?

If you don't know how to do that, I'd recommend This Article.

This topic is closed to new replies.

Advertisement