質問

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);
役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top