Originally, I was using individual textures (ie, individual .png files) for my sprite's animation and recently altered my code so that I could put all my animation frames into 1 file (so it basically is like a mini sprite sheet - I say 'mini' because I'm using 1 file per sprite, I'm not using 1 file for all my sprites).
Anyway my question relates to glBindTexture. Originally, I was switching textures when I wanted to update the animation frame so was calling this in my sprite's draw method:
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texID); //texID being the texture ID
However, now what happens is that I work out the texture offset and just point to part of the texture that I require. The texture itself does not change anymore, so do I still require this line every time I draw?
I tried removing the line from my draw() method and just calling it once when I loaded the texture initially, but the sprite doesn't draw with the correct texture, it uses a completely different, un-related texture. So what is the correct course of action in cases like this where a sprite-sheet is being used?
At the moment, I'm not sure why this would be any faster than using individual files and switching the texture every frame. In fact as I'm now having to work out the texture offset (whereas previously it was fixed), there is more overhead. So I'm guessing the advantage comes from not having to call this glBindTexture line every time I draw (as it's expensive). So how do I correctly choose the texture to assign to this sprite other than within the draw method?
Any help would be appreciate, if you need code please ask I didn't post my whole draw method as I didn't think it was necessary to explain the issue.
This is what I was doing previously
Bind texture 1 (Animation frame 1, textures 1-8 belong to this sprite) Draw Sprite 1 Bind texture 9 Draw Sprite 2
Repeat binding texture 2, then 3 etc for sprite 1 to animate it
I am now using a single texture for sprite1 which contains all 8 animation frames
Bind texture 1 (all frames) Draw Sprite 1 (pointing to frames 1, 2, 3 etc) Bind texture 5 draw sprite 2