Jump to content
  • Advertisement
Sign in to follow this  
arone

Caching a rendered image

This topic is 5409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by arone
This works ok but I'm not sure if it's the best way to do it;
In my opinion, this is the most straightfoward way. It's pretty simple:

- 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!