Skip to main content
gamedev.net
🔒 Locked

taking rendered data from BackBuffer

Started by shvalb Jan 14, 2005 at 4:43 AM 4 replies 1.4k views
Original Post
shvalb
shvalb
Hi. I'm interested to take the rendered data from the backbuffer and save it to an AVI file. today, I'm able to present the data to the screen and use the GetFrontBufferData() to get the data and store it in Avi file. How can I do it from the backbuffer ??? Here is my 'today' code: .. ... D3DDISPLAYMODE displayMode; LPDIRECT3DSURFACE9 pd3dsFront = NULL; m_pD3d_Device->GetDisplayMode(0, &displayMode); m_pD3d_Device->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height,D3DFMT_A8R8G8B8,D3DPOOL_SYSTEMMEM, &pd3dsFront, NULL); if (m_fullscreenFlag == true) {// Get the front buffer and save it to a file retVal = m_pD3d_Device->GetFrontBufferData(0, pd3dsFront) ; } else { retVal = m_pD3d_Device->GetRenderTarget(0, &pd3dsFront) ; } if(retVal == D3D_OK ) { brBitmap testbrBitmap ; LPBITMAP temp = NULL ; LPD3DXBUFFER myBuf ; retVal = D3DXCreateBuffer(sizeof(LPBYTE),&myBuf) ; if (retVal == D3D_OK) { retVal = D3DXSaveSurfaceToFileInMemory &myBuf,D3DXIFF_DIB,pd3dsFront,NULL,&m_rect); if (retVal == D3D_OK) { temp = (LPBITMAP)myBuf->GetBufferPointer() ; testbrBitmap.setBitmapByFrame(temp); retVal = m_pTbrAviMovie->addFrame(&testbrBitmap); } } } Thanks
Muhammad Haggag
Muhammad Haggag
IDirect3DDevice9::GetBackBuffer(), and then D3DXSaveSurfaceToFileInMemory.

shvalb
shvalb
I tried using the GetBackBuffer() instead of GetFrontBufferData(), but it doesn't work, it doesn't put the backbuffer to the file.
any idea why ?
jollyjeffers
jollyjeffers
Quote:
I tried using the GetBackBuffer() instead of GetFrontBufferData(), but it doesn't work

Did you check any return codes or debug output?

Messing with these calls and incorrect parameters will often fail the call and spit out an error code/message.

Having looked at the SDK documentation for GetBackBuffer() its quite specific on some of the params..

"Back buffers are numbered from 0 to the total number of back buffers minus one."

"Stereo view is not supported in Microsoft DirectX 9.0, so the only valid value for this parameter is D3DBACKBUFFER_TYPE_MONO."

"Failure to call IUnknown::Release when finished using this IDirect3DSurface9 interface results in a memory leak."


You sure that it's not giving you any data to work with because its failing at some point?

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
shvalb
shvalb
welp, when I switched to the GetBackBuffer() it didn't return any error code, but it didn't put the data in my Avi file.

Question: suppose my program at some point calls to the Present(), does it mean that it empties the backbuffer and moves the data to the frontbuffer and maybe that's why I get an empty avi file ???
jollyjeffers
jollyjeffers
Quote:
does it mean that it empties the backbuffer and moves the data to the frontbuffer

Yes, it will do something like this (it usually just swaps the pointers round). Depends how you set up your device's D3DPRESENT_PARAMETERS structure (the D3DSWAPEFFECT field in particular).

If you want the contents of the backbuffer of the current frame, you're probably best off doing it as the call immediately BEFORE the Present( ) operation.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.