RenderTarget2D is like a special kind of texture that we can draw things too. So instead of drawing our scene directly to the game window (aka backbuffer), we're instead going to draw our scene to a render target. By doing this, when we do our scene transitions, we can manipulate the render target before we draw it the the screen to create the transition effects.
There are a few caveats to using render targets that we need to be aware of, and we need to make sure that we handle them properly.
RenderTarge2Dinstance is a graphical resource object that we are creating manually. This means its life cycle is not managed by the
ContentManagerlike a normal textures, and we'll need to handle disposing of it properly when no longer needed.
- The contents of the
RenderTarget2Dwhen we draw to it reside in VRAM. Due to this, anytime a
GraphicsDevice.DeviceResetevent occurs, all contents of VRAM are discarded and the
RenderTarget2Dinstance will need to be recreated again. (this isn't as scary as it sounds).
So, with these points in mind, let's get started updating our scene demo.