Reputation: 19
I am aware that this topic has already been brought up, but I never could get anything out of the page. One clue to my answer was that I need to split up the GIF into each of its frames, but how? Some code along with this would be greatly appreciated. Thanks a lot.
Upvotes: 1
Views: 6978
Reputation: 61
Use GIFLIB to read gif animations. GIFLIB provides a handy "slurp" function that reads the entire file into structs that you can then pretty easily retrieve your frames from. It's been a while but IIRC when building an SDL_Texture
from the one gif frame you will need to look up colors from a palette for each pixel. Since gifs don't have one fixed frame rate you will also need to store the individual delay times for each frame. Read this for a detailed description of the gif file format and it will help you make sense of GIFLIB.
That said, I would advise against using the clunky GIF format for cutscenes (and most other things) because it's pretty space hungry and you may have problems syncing up your audio nicely. I would recommend looking around for a way to play "real" video formats -- take a look at this project.
Upvotes: 2