I want to animate a some numbers in openGl ES 2.0. To try and make it work to start with I have created a timer and am trying to get the numbers to change dependant on the timer. The timer is set up on a sin() wave so the numbers should increase then decrease again. The numbers are on the top line of the texture atlas so by increasing the texture coordinates in the x direction moves it up to the next number. I have tried using the fragment shader with if statements to move the texture coordinates but have had no luck. Im sure there must be a better way of doing this.
Fragment Shader
char FragShader[] =
"precision highp float;\n"
"varying highp vec2 textureCoordinate;\n"
"uniform sampler2D Texture;\n"
"uniform float time;\n"
"void main()\n"
"{\n"
"float c1 = 0.5*sin(time)+0.5;\n"
"if (c1 >= 0.0 && c1 < 0.1)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x, 1.0 -textureCoordinate.y);\n"
"elseif (c1 >= 0.1 && c1 < 0.2)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.1, 1.0 -textureCoordinate.y);\n"
"elseif (c1 >= 0.2 && c1 < 0.3)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.2, 1.0 -textureCoordinate.y);\n"
"elseif (c1 >= 0.3 && c1 < 0.4)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.3, 1.0 -textureCoordinate.y);\n"
"elseif (c1 >= 0.4 && c1 < 0.5)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.4, 1.0 -textureCoordinate.y);\n"
"elseif (c1 >= 0.5 && c1 < 0.6)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.5, 1.0 -textureCoordinate.y);\n"
"elseif (c1 >= 0.6 && c1 < 0.7)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.6, 1.0 -textureCoordinate.y);\n"
"elseif (c1 >= 0.7 && c1 < 0.8)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.7, 1.0 -textureCoordinate.y);\n"
"elseif (c1 >= 0.8 && c1 < 0.9)"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.8, 1.0 -textureCoordinate.y);\n"
"else"
"vec2 flipped_texcoord = vec2(textureCoordinate.x+0.9, 1.0 -textureCoordinate.y);\n"
"vec4 colour = texture2D(Texture, flipped_texcoord);\n"
"gl_FragColor = colour;\n"
"}\n";