text - Best way to animate textures in OpenGL ES 2.0 -


i want animate numbers in opengl es 2.0. try , make work start have created timer , trying numbers change dependant on timer. timer set on sin() wave numbers should increase decrease again. numbers on top line of texture atlas increasing texture coordinates in x direction moves next number. have tried using fragment shader if statements move texture coordinates have had no luck. im sure there must 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"; 

ok, such basic fix, 'elseif' should have been 'else if'. problem spanning lack of knowledge of c++ coding.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -