Reputation: 169
I am trying to store and display a map for an RTS game as a texture2d, but the map is too big, and I get the error "XNA Framework HiDef profile supports a maximum Texture2D size of 4096". The reason I wanted the entire map in one texture was so I could take advantage of the source/destination rectnagle draw method that spriteBatch has for use in the games camera. If this isn't obviously a bad idea, how can I store and display large images?
Upvotes: 0
Views: 4353
Reputation: 27195
You can't get around the texture size limit in XNA. It's quite reasonable to use multiple textures and draw them in different places. It is only a small amount of extra logic to handle the borders.
Don't forget that a 4096 by 4096 texture is already a whopping 64MB of texture memory, uncompressed (and at least 10MB if DXT compressed).
If you're concerned about performance - don't be. The "source rectangle" parameter enables texture atlasing - this is not what you're doing here, though.
Furthermore, it is usually best to implement a game camera by passing a translation Matrix
to SpriteBatch.Begin
, and then Draw
ing everything (background included) at fixed coordinates. You don't even need to specify a source rectangle for the background - the viewport will simply clip it.
If you wish to import textures that are larger than 4096 square, you could create a content pipeline extension to cut those large textures up into smaller ones. Or, if you only have a handful of fixed maps, it is easier just to separate them in your image editor.
Upvotes: 2