src/render/opengles2/SDL_shaders_gles2.c
changeset 12156 e5a666405750
parent 11811 5d94cb6b24d3
child 12208 abf1ced78a16
equal deleted inserted replaced
12155:751cdc74d55c 12156:e5a666405750
    28 #include "SDL_stdinc.h"
    28 #include "SDL_stdinc.h"
    29 
    29 
    30 /*************************************************************************************************
    30 /*************************************************************************************************
    31  * Vertex/fragment shader source                                                                 *
    31  * Vertex/fragment shader source                                                                 *
    32  *************************************************************************************************/
    32  *************************************************************************************************/
    33 
    33 /* Notes on a_angle:
       
    34    * It is a vector containing sin and cos for rotation matrix
       
    35    * To get correct rotation for most cases when a_angle is disabled cos
       
    36      value is decremented by 1.0 to get proper output with 0.0 which is
       
    37      default value
       
    38 */
    34 static const Uint8 GLES2_VertexSrc_Default_[] = " \
    39 static const Uint8 GLES2_VertexSrc_Default_[] = " \
    35     uniform mat4 u_projection; \
    40     uniform mat4 u_projection; \
    36     attribute vec2 a_position; \
    41     attribute vec2 a_position; \
    37     attribute vec2 a_texCoord; \
    42     attribute vec2 a_texCoord; \
    38     attribute float a_angle; \
    43     attribute vec2 a_angle; \
    39     attribute vec2 a_center; \
    44     attribute vec2 a_center; \
    40     varying vec2 v_texCoord; \
    45     varying vec2 v_texCoord; \
    41     \
    46     \
    42     void main() \
    47     void main() \
    43     { \
    48     { \
    44         float angle = radians(a_angle); \
    49         float s = a_angle[0]; \
    45         float c = cos(angle); \
    50         float c = a_angle[1] + 1.0; \
    46         float s = sin(angle); \
       
    47         mat2 rotationMatrix = mat2(c, -s, s, c); \
    51         mat2 rotationMatrix = mat2(c, -s, s, c); \
    48         vec2 position = rotationMatrix * (a_position - a_center) + a_center; \
    52         vec2 position = rotationMatrix * (a_position - a_center) + a_center; \
    49         v_texCoord = a_texCoord; \
    53         v_texCoord = a_texCoord; \
    50         gl_Position = u_projection * vec4(position, 0.0, 1.0);\
    54         gl_Position = u_projection * vec4(position, 0.0, 1.0);\
    51         gl_PointSize = 1.0; \
    55         gl_PointSize = 1.0; \