Retrieve the back buffer call the getbackbuffer method idirect ddevice
44 |
|
---|
�NOTE. Here are some important rules to remember when surface copying:
• The source surface must have been created with
D3DPOOL_SYSTEMMEM.• The source and dest rects must fit within the surface.
• No stretching or shrinking is allowed (the rects must be the same size).
HRESULT GetBackBuffer
(
UINT iSwapChain,
UINT BackBuffer,
D3DBACKBUFFER_TYPE Type,
|
---|
|
Chapter 2 |
---|
A value of 0 returns the first back buffer. For the purposes of this book, pass 0.
The code to get the back buffer and copy a surface onto it might look like the following. Be sure to copy your surface onto the back buffer between the BeginScene and EndScene statements of the rendering loop, which occurs on each frame. This will ensure your data gets copied onto the back buffer correctly and that it’ll be visi-ble as the frame is presented.
if(SUCCEEDED(g_pd3dDevice->BeginScene()))
{
//Draw stuff here
IDirect3DSurface9 *BackBuffer = NULL;
g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, & BackBuffer); g_pd3dDevice->UpdateSurface(SourceSurface, NULL, BackBuffer, NULL);