Reputation: 599
in my openglES context i want to animate one texture, but the datas for this texture may be change lot of time per second ( like a video frame, but more slow ). the idea is to animate a simple rectangle surface in my 3D scene.
In my mind the fast technique to realize this it's to load some next textures in memory ( by loading in CGImageREF in other Thread) and push the data on my texture just before using this.
Can you think about this ?
Thanks a lot
Upvotes: 1
Views: 316
Reputation: 18418
You can see this cover flow sample code. It will store the textures in a container (array or dictionary), and retrieve these textures as necessary. But keep this in mind, a texture will occupy physical memory. If your texture is 256x256, it will occupy 256x256x4 bytes (256KB). If you stores too many textures, it is easy to receive iOS's memory warning.
Upvotes: 2
Reputation: 515
You might take an approach similar to UITableView's handing for row views in which you manage a queue of some number of reusable textures. As you need frames, dequeue the next texture in that queue, load the new image into it and add it to a different queue of loaded textures ready to be displayed at the appropriate time. After you swap out a frame, enqueue the previously displayed texture in your queue again so it can be reused later.
Upvotes: 1