Hey amigos. Here is a quick block for a more advanced playback of animated gifs. It takes into account that framerates can be different between every single frame, and also exposes global palettes often included in gifs. While I don’t recommend using a lot of gifs in your project, it’s something that gets requested enough from clients that I finally made this so I could stop worrying about it. Use is super simple.
ciAnimatedGifRef mGif = ciAnimatedGif::create( loadAsset("someGif.gif") ); mGif->draw();
Find the block here: https://github.com/cwhitney/ciAnimatedGif
It’s based on the information in this article: http://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html
Now - a question! When I load the gif frames, I am storing them as a vector of Surfaces. When they get displayed, I convert it to a texture right before it displays, which means an upload to the gpu. The alternative is to upload every frame to the gpu at the beginning, and just leave them there with gl::TextureRefs. I did it this way because if you’re displaying gifs, then you might be displaying a lot of them, and I didn’t want to clog the gpu, especially if you’re not displaying them. How would you handle this?