0
votes

How can I join together multiple Texture2D's into one large Texture2D? I am trying to optimize an isometric tile game by splitting the map up into chunks.

I have tried googling it, and found articles regarding "RenderTarget2D", but am unsure how to implement this.

Thanks, Sam.

1

1 Answers

0
votes

Never mind - I worked it out.

For anyone who is also looking for this, you basically draw onto a "RenderTarget2D", as you would onto the screen, using the spriteBatch.

(helpful article)

RenderTarget2D render;    //declare target

render = new RenderTarget2D(GraphicsDevice, (int)(tileSize.X * numberOfTiles.X), (int)(tileSize.Y * numberOfTiles.Y), 0, SurfaceFormat.Color); //assign target, where tileSize is the size of a tile and numberOfTiles is the number of tiles you are rendering

GraphicsDevice.SetRenderTarget(0, render); //Target the render instead of the backbuffer

batch.Begin();
//draw each tile
batch.End();

GraphicsDevice.SetRenderTarget(0, null); //target the backbuffer again

Texture2D myTexture = render.GetTexture(); //store texture in Texture2D variable

Sorry for the rather poor explanation - my first try at a tutorial.