5 edited body edited Nov 16 '12 at 10:51 Marco Martinelli 42111 gold badge44 silver badges99 bronze badges gl.glEnable(GL10.GL_TEXTURE_2D); gl.glMatrixMode(GL10.GL_TEXTURE); //edit the texture matricmatrix gl.glTranslatef(u, v, 0); //translate the uv space (you can also rotate, scale, ...) gl.glMatrixMode(GL10.GL_MODELVIEW); //go back to the modelview matrix gl.glBindTexture(GL10.GL_TEXTURE_2D, getTexture()); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); //map the texture on the triangles gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, getTextureBuffer()); //load texture coordinates  gl.glEnable(GL10.GL_TEXTURE_2D); gl.glMatrixMode(GL10.GL_TEXTURE); //edit the texture matric gl.glTranslatef(u, v, 0); //translate the uv space (you can also rotate, scale, ...) gl.glMatrixMode(GL10.GL_MODELVIEW); //go back to the modelview matrix gl.glBindTexture(GL10.GL_TEXTURE_2D, getTexture()); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); //map the texture on the triangles gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, getTextureBuffer()); //load texture coordinates  gl.glEnable(GL10.GL_TEXTURE_2D); gl.glMatrixMode(GL10.GL_TEXTURE); //edit the texture matrix gl.glTranslatef(u, v, 0); //translate the uv space (you can also rotate, scale, ...) gl.glMatrixMode(GL10.GL_MODELVIEW); //go back to the modelview matrix gl.glBindTexture(GL10.GL_TEXTURE_2D, getTexture()); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); //map the texture on the triangles gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, getTextureBuffer()); //load texture coordinates  4 added 2 characters in body edited Sep 24 '12 at 10:29 Marco Martinelli 42111 gold badge44 silver badges99 bronze badges when you do idx%c you find youyour column index, the results is always between 0 and c-1 idx/c is the same thing but for rowrows, idx and c are both integer so the result is still integer, and it's the row index, dividing by rf you get a value between 0.0 and 1.0 when you do idx%c you find you column index, the results is always between 0 and c-1 idx/c is the same thing but for row, idx and c are both integer so the result is still integer, and it's the row index, dividing by rf you get a value between 0.0 and 1.0 when you do idx%c you find your column index, the results is always between 0 and c-1 idx/c is the same thing but for rows, idx and c are both integer so the result is still integer, and it's the row index, dividing by rf you get a value between 0.0 and 1.0 3 added 1082 characters in body edited Sep 24 '12 at 10:21 Marco Martinelli 42111 gold badge44 silver badges99 bronze badges ok, let's take 5 rows and 4 columns as an example. There are max 20 sprites in your spriteset so use int idx = (int)((System.currentTimeMillis()%200*number_of_sprites)))/200); idx now go from 0 to number_of_sprites-1 (can be < 20 if you have for example 5 rows, 4 columns but only 18 sprite) changing it's value every 200ms. Assuming you have your sprite from left to right and from top to bottom than you can find your frame coordinate in uv space doing this.int c = 4; //number of columns as int float cf = 4.f; //number of columns as float float rf = 5.f; //number of rows as float gl.glTranslatef((idx%c)/cf, (idx/c)/rf, 0);  when you do idx%c you find you column index, the results is always between 0 and c-1 idx%c is an integer, you need to scale it to a value between 0.0 and 1.0 so you divide by cf, cf is a float so there is an implicit cast here idx/c is the same thing but for row, idx and c are both integer so the result is still integer, and it's the row index, dividing by rf you get a value between 0.0 and 1.0 ok, let's take 5 rows and 4 columns as an example. There are max 20 sprites in your spriteset so use int idx = (int)((System.currentTimeMillis()%200*number_of_sprites)))/200); idx now go from 0 to number_of_sprites-1 (can be < 20 if you have for example 5 rows, 4 columns but only 18 sprite) changing it's value every 200ms. Assuming you have your sprite from left to right and from top to bottom than you can find your frame coordinate in uv space doing this.int c = 4; //number of columns as int float cf = 4.f; //number of columns as float float rf = 5.f; //number of rows as float gl.glTranslatef((idx%c)/cf, (idx/c)/rf, 0);  when you do idx%c you find you column index, the results is always between 0 and c-1 idx%c is an integer, you need to scale it to a value between 0.0 and 1.0 so you divide by cf, cf is a float so there is an implicit cast here idx/c is the same thing but for row, idx and c are both integer so the result is still integer, and it's the row index, dividing by rf you get a value between 0.0 and 1.0 2 added 272 characters in body edited Sep 24 '12 at 8:16 Marco Martinelli 42111 gold badge44 silver badges99 bronze badges 1 answered Sep 23 '12 at 20:37 Marco Martinelli 42111 gold badge44 silver badges99 bronze badges