I have been looking for an answer but haven’t found anything specific about it.
I’d like to know what of these two examples is better related with speed and performance. Thanks in advance!
I am making a openGL ES 1.0 Android Game in 2D. For animating the characters I use different textures. I have two posibilities with the textures:
First one is to have each texture in an int Array and change which one is selected depending on the frame with:
gl.glBindTexture(GL10.GL_TEXTURE_2D, texture[actual_id]);
On the other hand we can have a “Big” texture with all the images and just modify the Texture coordinates. In this case instead of:
private float textures[] = {
// Mapping coordinates for the vertices
0.0f, 1.0f, // top left (V2)
0.0f, 0.0f, // bottom left (V1)
1.0f, 1.0f, // top right (V4)
1.0f, 0.0f // bottom right (V3)
};
(Which would be the one in the first case) It would be:
private float textures[] = {
// Mapping coordinates for the vertices
0.0f, 0.5f, // top left (V2)
0.0f, 0.0f, // bottom left (V1)
0.5f, 0.5f, // top right (V4)
0.5f, 0.0f // bottom right (V3)
};
(Using a 2×2 box) And those coordinates should move around the texture.
I would like to know which may be the fastest. Also, if there is a third best way I’d love to know about it.
Thanks for your time. If I have to detail the question please ask me.
I think there is no general answer to this question because it depends on some other things.
I assume you have a lot of other objects besides the characters to draw. Lets assume you have a game loop that looks something like this:
In this case you have to change to the character texture anyway. The first way would be the better solution because the smaller texture requires less texture memory.
But if your loop looks like this:
In this case you can profit from the second way because you can display multiple characters in different animation states without changing the texture.
I don’t know if there is any real alternative with OpenGl ES 1.0. With ES 2.0 you would have the option to use one texture for multiple animation states (like your 2nd approach) and compute the texture coordinate offsets within the shader (so you don’t need multiple texture coordinate arrays).