views:

562

answers:

1

I'm writting a small game in OpenGL, where I represent Items, enemies, characters, ect with a class. Each class saves references to one or more objects from an Animation class. An animation class contains references to one or more frames, which are textures I already loaded using openGL. Whenever I rotate, scale, ect any element in the game I save the data of such transformations. Right now I recalculate ( I don't use the tranformations provided by openGL) the coordinates of each texture each frame at the moment of drawing, without saving them.

Not like I'm trying to optimize already, but I wonder which one is the best approach when programming for Iphone... It's better to save in your objects all the information you need ?... or It's better to re-calculate and leave most of the work to the CPU.

+1  A: 

How much data are you talking about, it seems like any transform information or coordinates are going to be trivially small compared to things like the actual textures.

I am guessing you are looking at between 8 and 64 bytes per on sprites, and at most maybe ~250 sprits? That will probably be less than 1 frame of animation for on sprite, and depending on the exact size of your objects and the extra data it might not take any extra space because of the granularity of the system malloc.

In other words, unless I am guessing wrong your data is completely in the noise and probably undetectable, definitely cache the values between frames.

Louis Gerbarg
That's pretty much what I wanted to know, thanks.
José Joel.