2D sprite animation using OpenGL ES 2.0: How to swap texture coordinate buffers?

I’m doing a 2D sprite animation using OpenGL ES 2.0. I see that it’s a bit tricky to constantly switch texture UV normalized coordinate buffers back and forth. I am wondering if there are other ways of achieving 2D sprite animations. Some people may ask why I’m using OpenGL ES instead of Canvas to draw sprite animations? The hardware I’m using states that if I switch to using Canvas, it automatically uses software rendering, and not hardware rendering. My aim is to use hardware rendering whenever I can. If I use software rendering, it gets pretty slow. Decent, but not good enough for me.

In immediate mode (OpenGL ES 1.1+), there’s a method that I can use to change the UV coordinates of a texture.

GLES11.glMatrixMode(GLES11.GL_TEXTURE)

However, I’m not sure of OpenGL ES 2.0’s equivalent alternative to that above.

Another method that I’m unsure of is the usage of 2-dimensional UV texture coordinates array. There may be probably some ways to use them.

One method that I’m sure I’m unable to do is 3D textures, where frame animations happen on the omega axis (w). Unfortunately, I lack the hardware to create them. I’m using a tablet for my dev environment and my testing hardware, so this isn’t feastible.

Anyone else knows about to do this?

The solution is to do it in shaders. You can simply increment the texture coords in the shader based on a uniform variable. This is essentially the equivalent of the function from GLES 1.1 that you mention. Since you didn’t come to this conclusion yourself I’m guessing you don’t know about shaders. They are very important in any modern graphics and I seriously advice you to learn about them before doing anything else. Seriously if you knew about shaders, this would be child’s play to you.

Link to good tutorial: http://www.lighthouse3d.com/tutorials/glsl-tutorial/. Weird, this is the third time I’ve linked this site in as many days.

Thanks for your help. I’ve successfully created an animation within such short notice. :smiley:

Happy to help.