Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to capture data from Back Buffer (DirectX9)
    primarykey
    data
    text
    <p>I am trying to find the fastest method to take the screenshot. So far I've figured out that either GDI, or DirectX can be used. Using GDI I am able to capture the screen in 35ms, while using DirectX Front buffer it takes 73ms average. I want even faster method than this. For this purpose capturing Back Buffer in DirectX seems to be a good method. I am using the following code to do the same:</p> <pre><code> D3DDISPLAYMODE ddm; D3DPRESENT_PARAMETERS d3dpp; if((g_pD3D=Direct3DCreate9(D3D_SDK_VERSION))==NULL) { ErrorMessage("Unable to Create Direct3D "); return E_FAIL; } if(FAILED(g_pD3D-&gt;GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&amp;ddm))) { ErrorMessage("Unable to Get Adapter Display Mode"); return E_FAIL; } ZeroMemory(&amp;d3dpp,sizeof(D3DPRESENT_PARAMETERS)); d3dpp.Windowed=WINDOW_MODE; d3dpp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; d3dpp.BackBufferFormat=ddm.Format; d3dpp.BackBufferHeight=nDisplayHeight=gScreenRect.bottom =ddm.Height; d3dpp.BackBufferWidth=nDisplayWidth=gScreenRect.right =ddm.Width; d3dpp.MultiSampleType=D3DMULTISAMPLE_NONE; // d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD; d3dpp.SwapEffect=D3DSWAPEFFECT_COPY; d3dpp.hDeviceWindow=hWnd; d3dpp.PresentationInterval=D3DPRESENT_INTERVAL_DEFAULT; d3dpp.FullScreen_RefreshRateInHz=D3DPRESENT_RATE_DEFAULT; if(FAILED(g_pD3D-&gt;CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING ,&amp;d3dpp,&amp;g_pd3dDevice))) { ErrorMessage("Unable to Create Device"); return E_FAIL; } if(FAILED(g_pd3dDevice-&gt;CreateOffscreenPlainSurface(ddm.Width, ddm.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &amp;g_pSurface, NULL))) { ErrorMessage("Unable to Create Surface"); return E_FAIL; } g_pd3dDevice-&gt;GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&amp;g_pSurface); D3DXSaveSurfaceToFile("d:\\v\\temp.bmp",D3DXIFF_BMP,g_pSurface,NULL,NULL); </code></pre> <p>The problem is, that the output file measures 5MB, but shows nothing but black color in the output. While in the same code if I use GetFrontBufferData I can successfully capture the screen. Am I doing anything wrong? Please help me.. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload