Sprites and animation with OpenGL ES
Posted: Wed Jan 13, 2010 11:03 am
So I have been getting back into my programming and have set up the better half of my C++ wrapper/game development framework for the iPhone. The framework is going to be designed to help me create 2d games quickly and as I am using openGL ES creating a sprite system for loading/storing/animating images is pretty important.
I have created a working, if slightly shotty animated sprite system however I'm trying to suss out what sort of approach is better when tackling this sort of things. The two approaches for this sort of a problem I have come up with and implemented are as follows;
*Loading a large series of sprites, each representing a different frame of the animation. Storing and displaying these appropriately (whether by indexing or otherwise placing them in arrays).
*Loading a sprite sheet, then adjusting the texture coordinates so only 1 frame is shown at a time. Then adjusting the texture coordinates being displayed upon going to the next frame in the animation.
The other solution is to load the sprite sheet and then store each frame individualy as in the first example.
Could someone give me a few tips of the kind of logic I should use to create a sprite class that is going to run fast and cost little in memory. I would assume simply shifting the texture coordinates is more costly at runtime, while having a large number of seperate images is more costly on memory and inconvenient.
Thanks in advance for any help you guys can provide.
I have created a working, if slightly shotty animated sprite system however I'm trying to suss out what sort of approach is better when tackling this sort of things. The two approaches for this sort of a problem I have come up with and implemented are as follows;
*Loading a large series of sprites, each representing a different frame of the animation. Storing and displaying these appropriately (whether by indexing or otherwise placing them in arrays).
*Loading a sprite sheet, then adjusting the texture coordinates so only 1 frame is shown at a time. Then adjusting the texture coordinates being displayed upon going to the next frame in the animation.
The other solution is to load the sprite sheet and then store each frame individualy as in the first example.
Could someone give me a few tips of the kind of logic I should use to create a sprite class that is going to run fast and cost little in memory. I would assume simply shifting the texture coordinates is more costly at runtime, while having a large number of seperate images is more costly on memory and inconvenient.
Thanks in advance for any help you guys can provide.