Make sprite animation

There are a bunch of great ways to do it. Using a spritesheet is definitely one of them. An advantage of something like a spritesheet is that when openGL binds a texture, it only has to do it once per frame, and not multiple times for different textures. This is especially helpful if you have a lot of instances of the same sprite on screen at once.

In the past when I’ve needed to bind a lot of textures and needed great performance, I’ve used 2D sampler arrays. These will let you pass in “3D” arrays of textures, and I think on my system I can pass up to 2048. GL_TEXTURE_2D_ARRAY is the thing to google. You’ll need to write a custom shader, and then in the texture lookup, you pass in a vec3 instead of a vec2, where the z is an index for which texture you’re looking up.

Lastly, a while back I made a simple block for animated gifs. New block - ciAnimatedGif Depending on your app structure and performance needs, this can also work in a pinch.

TLDR: Try spritesheets, and gifs in that order. If you need performance, check out GL_TEXTURE_2D_ARRAY.

1 Like