src/render/opengles2/SDL_shaders_gles2.c
changeset 12156 e5a666405750
parent 11811 5d94cb6b24d3
child 12208 abf1ced78a16
     1.1 --- a/src/render/opengles2/SDL_shaders_gles2.c	Mon Aug 27 11:51:05 2018 -0700
     1.2 +++ b/src/render/opengles2/SDL_shaders_gles2.c	Tue Aug 28 12:57:51 2018 -0700
     1.3 @@ -30,20 +30,24 @@
     1.4  /*************************************************************************************************
     1.5   * Vertex/fragment shader source                                                                 *
     1.6   *************************************************************************************************/
     1.7 -
     1.8 +/* Notes on a_angle:
     1.9 +   * It is a vector containing sin and cos for rotation matrix
    1.10 +   * To get correct rotation for most cases when a_angle is disabled cos
    1.11 +     value is decremented by 1.0 to get proper output with 0.0 which is
    1.12 +     default value
    1.13 +*/
    1.14  static const Uint8 GLES2_VertexSrc_Default_[] = " \
    1.15      uniform mat4 u_projection; \
    1.16      attribute vec2 a_position; \
    1.17      attribute vec2 a_texCoord; \
    1.18 -    attribute float a_angle; \
    1.19 +    attribute vec2 a_angle; \
    1.20      attribute vec2 a_center; \
    1.21      varying vec2 v_texCoord; \
    1.22      \
    1.23      void main() \
    1.24      { \
    1.25 -        float angle = radians(a_angle); \
    1.26 -        float c = cos(angle); \
    1.27 -        float s = sin(angle); \
    1.28 +        float s = a_angle[0]; \
    1.29 +        float c = a_angle[1] + 1.0; \
    1.30          mat2 rotationMatrix = mat2(c, -s, s, c); \
    1.31          vec2 position = rotationMatrix * (a_position - a_center) + a_center; \
    1.32          v_texCoord = a_texCoord; \