Search code examples
c#xnaxna-4.0

Dealing with resizing windows and RenderTargets in XNA


I am designing a gui system for my XNA game. The window can be dynamically resized at runtime and the 'desktop' resizes to it fine.

However my rendering now uses render targets to render the windows and effects. If the window or any of the components resize how do I handle the render targets? The cant be resized dynamically and creating new ones every loop would be incredibly inefficient.


Solution

  • You can create new render targets when the window is resized. No need to recreate them every frame.

    Another option is to create a render target bigger than needed and only use the part you need. That means you will have to remap your post effects UVs in some way. This might help with memory fragmentation, but personnaly, I never had any problem with the first method of just recreating the render targets when needed.