1

I'm using RenderTarget2D to draw my map to before rendering it to the screen as it changes very rarely and the map itself is made up of a LOT of very small tiles. So rather than drawing all tiles to the buffer every frame, I'm drawing them to a RenderTarget2D which I then draw to the buffer.

My question is in regards to the RenderTarget2D "texture". If the player was to resize the window, which I want to enable at least to play with a little, what is the proper way to modify the RenderTarget2D object in regards to dimensions?

At the moment I'm just recreating the object anytime the window is resized which may be fine, but I figured I should ask to be safe I'm not missing something simpler.

texMap = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
Mythics
  • 773
  • 1
  • 10
  • 19
  • Note that I'm not really understanding what I'm doing, so it should be mentioned that my current method is a rather bad one as it causes a memory leak it would seem. Perhaps I need to manually unallocate the RenderTarget2D prior to recreating it? – Mythics Dec 13 '12 at 18:16

1 Answers1

3

There is no way to resize a render target after it's been created. Call Dispose() on the existing render target, if it exists, and then create a new one.

Cole Campbell
  • 4,846
  • 1
  • 17
  • 20