Algorithms to create sprite sheets?

Started by
6 comments, last by riruilo 14 years, 8 months ago
Hi friends! I have to create a sprite sheet processor for a game I'm doing for the iPhone. That is, given several images (different sizes, non-square and non-power-of-two) put all of them in one (or more) files. Requeriments: -I'd to maximize the number of images I put on the sprite sheet. -I'd to minimize the size of sprite (must be square and power of two) and the number of sprite sheets (iPHone supports 1024*1024 so I guess I have to create several sprite sheets ) -Apart from creating this file, I have to create another one with image names and texture coordinates. Guess this is the easiest part. My question is: what kind of algorithm should I use to solve this max/min problem? All ideas are welcome! Thanks in avanced!
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Advertisement
Search the internet and/or the forum archives for 'bin packing' and you'll find plenty of info.
I don't know if you *need* to write it or just have a solution, but it's already been done many times. This tool is pretty handy and does exactly what you are asking:

http://forums.indiegamer.com/showthread.php?t=18027

Which is to create a texture atlas and corresponding data file.

Edit: You can also check out ImageMagick and its Montage feature :)
Thanks for the info, I will so it!

I'd like to write it, instead of using another solution, but it's nice to have several choices.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
If you want to see how I created my own sprite sheet for use in OpenGL, have a look at this video tutorial.

http://www.marek-knows.com/downloadSection.php?Topic=OpenGL&pg=1#OpenGL6

Quote:Original post by mmakrzem
If you want to pay to see how I created my own sprite sheet for use in OpenGL, have a look at this video tutorial.

Fixed.
Off topic but why do you never say this in your posts?
A simple tutorial.
Quote:Original post by Dave
A simple tutorial.


I think that is exactly what I was looking for. Thanks a lot.

Edit: @Dave: Are you the author of that website?
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.

This topic is closed to new replies.

Advertisement