Caching a rendered image
I have an application that sometimes needs several seconds or even minutes to render an image. I'd like to cache the latest rendered image so that when the window is repainted I'd only draw the cached image instead of starting a new rendering. What's the best way to do this? I've tried creating a texture in D3DPOOL_SYSTEMMEM with the same size as the viewport and then (managed DirectX, C#):
device.GetRenderTargetData(device.GetRenderTarget(0), texture.GetSurfaceLevel(0));
When the window is repainted I'll just draw the texture on a single viewport-sized quad. This works ok but I'm not sure if it's the best way to do it; I was thinking maybe the same thing can be done by using swap-chain buffers in some clever way so that I don't have to keep my own texture and update it on window size changes etc...any ideas?
Quote:Original post by aroneIn my opinion, this is the most straightfoward way. It's pretty simple:
This works ok but I'm not sure if it's the best way to do it;
- Render the scene to the texture, instead of the backbuffer, using ID3DXRenderToSurface or IDirect3DDevice9::SetRenderTarget().
- Render that texture to the screen using ID3DXSprite or a quad.
If I was you I'd try this: Render your scene, and in the next frame just flip the back-buffers (without clearing them or rendering something new). Whatever you rendered last will be left in the back buffer unles you clear it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement