Capturing FrontBuffer and Rendering it

Started by
0 comments, last by gamerhub 3 months, 1 week ago

Hi , I am new to DirectX , I am trying to capture the screen of my desktop and display it on my DirectX application.

As far as I have understood , I need to use GetFrontBufferData() for this

void render_frame(void)

{

d3ddev->BeginScene(); // begins the 3D scene

d3ddev->Clear(0, 0, D3DCLEAR_TARGET,NULL,NULL,NULL);

d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);

d3ddev->CreateOffscreenPlainSurface(300, 500, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &g_pSurface, NULL);

d3ddev->CreateOffscreenPlainSurface(400, 600, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &dest_Surface, NULL);

d3ddev->GetFrontBufferData(0, g_pSurface);

d3ddev->UpdateSurface(g_pSurface, NULL, dest_Surface, NULL);

d3ddev->GetRenderTargetData(g_pSurface, dest_Surface);

d3ddev->StretchRect(dest_Surface, NULL, backbuffer,NULL, D3DTEXF_NONE);

d3ddev->EndScene();

d3ddev->Present(NULL, NULL, NULL, NULL); // displays the created frame on the screen

}

I am using the above method to render , but all I am getting is black screen , I happento be new to DirectX , please guide me in the right direction

This topic is closed to new replies.

Advertisement