• Advertisement
Sign in to follow this  

Textures for sprite storage

This topic is 4248 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm going to be trying to write some code over the weekend for loading individual images and placing them on a locked texture in such a way that I can use a single texture for different sprites while still having seperate image files outside the program. What's the best way to structure the texture? Wide, with sprites running across, or tall with sprites running down? Or would it be better to have a large square texture with the sprites "gridded"? Or is it irrelevant? I remember some old cards wouldn't let me create DirectDraw surfaces that were wider than the current display mode years ago.

Share this post


Link to post
Share on other sites
Advertisement
What you are looking for is called “Texture Atlas“. As I am to lazy to write I am give you a link to a good white paper: http://download.nvidia.com/developer/NVTextureSuite/Atlas_Tools/Texture_Atlas_Whitepaper.pdf

Share this post


Link to post
Share on other sites
Hi EasilyConfused,

I will describe what I have done for our tile based RPG, which uses a similar scheme to what you're looking for.

There are 2 datafiles which describe the bitmap imagery in the game. They are in textfile 2da format (tab-separated 2 dimensional array files similar in layout to a spreadsheet). The first describes the bitmaps used: their width/height, the number of tiles (e.g. sub-bitmap) X and Y, the width/height of each tile, and color key information.

The second datafile is a tile index list; each tile is given a unique identifier, and refers to a bitmap index, and tile X/Y within that bitmap to pull the texture information.

Each bitmap is a grid of tiles, for example one 1024x1024 grid might have 64x64 pixel tiles on it (e.g. 16x16 tiles), hence tile #42 would refer to the tile at (10, 2) on the grid. Furthermore, animated sprites in the game refer to tile indices for frames.

I'm sure there are other methods of handling sub-bitmaps, but I found this system the easiest to manage and get up and running in a short period of time.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement