Unable to capture data from Back Buffer (DirectX9)

风格不统一 提交于 2019-12-06 09:52:17

Here's how I take a screenshot:

IDirect3DSurface9 *offscreenSurface = 0;
d3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &offscreenSurface);
D3DXSaveSurfaceToFile( filename, D3DXIFF_BMP, offscreenSurface, 0, 0 )

Note that this code is run before Present is called.

You cannot capture a screen shot from the backbuffer.

The frontbuffer-backbuffer relationship works like this: the backbuffer is wiped, and then has the scene drawn to it one draw-call at a time. As soon as it's ready it's flipped with the frontbuffer so the frontbuffer gets the final image to display while the backbuffer is again wiped.

Theoretically there is a point where the backbuffer has the data you want, but I do not believe you can reliably get this state. The frontbuffer is designed for this task.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!