Progress bar rendering

Started by
3 comments, last by scippie 17 years, 6 months ago
Hi, For our game, I sometimes need to show a progress bar when content is downloaded. I want to do this without continuously rendering the background, but by just taking a screenshot of the window and using that as a background for the progress-bar rendering cyclus. This is only necessary for full-screen as there is swapping. In windowed mode, I can just draw over the last rendered frame without clearing the backbuffer. So I: ... m_pD3DDevice->CreateTexture(resx,resy,1,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&m_texBBCopy,NULL); ... ... IDirect3DSurface9 *srfBBCopy; IDirect3DSurface9 *srfBackBuffer; if (FAILED(hr=m_texBBCopy->GetSurfaceLevel(0,&srfBBCopy))) throw DException(hr,"RenderProgress - Failed to GetSurfaceLevel"); if (FAILED(hr=m_pD3DDevice->GetFrontBufferData(0,srfBBCopy))) throw DException(hr,"Failed to GetFrontBufferData"); // Repeat this for backbuffer-count if (FAILED(hr=m_pD3DDevice->GetBackBuffer(0,ibb,D3DBACKBUFFER_TYPE_MONO,&srfBackBuffer))) throw DException(hr,"RenderProgress - Failed to GetBackBuffer 0"); if (FAILED(hr=m_pD3DDevice->UpdateSurface(srfBBCopy,NULL,srfBackBuffer,NULL))) throw DException(hr,"RenderProgress - Failed to UpdateSurface 0"); // End repeat srfBackBuffer->Release(); srfBBCopy->Release(); Now, the code fails on GetFrontBufferData with the cryptic error: D3DERR_INVALIDCALL Can anyone tell me what I'm doing wrong?
Advertisement
srfBBCopy has to be a valid surface, not just an empty pointer afaik. Create a surface with the size of the backbuffer.
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
Quote:Original post by darkelf2k5
srfBBCopy has to be a valid surface, not just an empty pointer afaik. Create a surface with the size of the backbuffer.


Hi,

The surface is not invalid afaik, I created a texture earlier and I get a surface from that texture with GetSurfaceLevel.
Missed that, my bad.

Well, it works for me if I create the surface like this:

dxutGetD3DDevice()->CreateOffscreenPlainSurface( D3DPP.BackBufferWidth, D3DPP.BackBufferHeight, D3DPP.BackBufferFormat, D3DPOOL_SYSTEMMEM, pFrontBufferData, NULL );

Try using SYSTEMMEM pool. Or CreateOffscreenPlainSurface instead of getting it from a texure.

Cheers
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
Quote:Original post by darkelf2k5
Try using SYSTEMMEM pool. Or CreateOffscreenPlainSurface instead of getting it from a texure.


Of course!! That must be it! I even read that part in the SDK stating that the surface should be in system memory.
How stupid of me!

Thanks dude!

This topic is closed to new replies.

Advertisement