XNA noob here, learning every day. I just worked out how to composite multiple textures into one using a RenderTarget2D. However, while I can use the RenderTarget2D as a Te
Actually your code is not so bad if you're generating textures in a once-off process when you'd normally load content (game start, level change, room change, etc). You're transferring textures between CPU and GPU, same thing you'd be doing loading plain ol' textures. It's simple and it works!
If you're generating your textures more frequently, and it starts to become a per-frame cost, rather than a load-time cost, then you will want to worry about its performance and perhaps keeping them as render targets.
You shouldn't get ContentLost
in the middle of drawing, so you can safely just respond to that event and recreate the render targets then. Or you can check for IsContentLost
on each of them, ideally at the start of your frame before you render anything else. Either way everything should be checked before your SpriteBatch
begins.
(Normally when using render targets you're regenerating them each frame anyway, so you don't need to check them in that case.)