Fixed bug 1335 - Added support for different pixel formats in OpenGL ES 2 renderer
authorSam Lantinga <slouken@libsdl.org>
Thu, 29 Dec 2011 05:11:33 -0500
changeset 611364742b8c8eb3
parent 6108 f3c34d321289
child 6114 d166819bf2b3
Fixed bug 1335 - Added support for different pixel formats in OpenGL ES 2 renderer

Gueniffey 2011-11-23 04:06:31 PST

The attached patch adds native support for
SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888
src/render/opengles2/SDL_render_gles2.c
src/render/opengles2/SDL_shaders_gles2.c
src/render/opengles2/SDL_shaders_gles2.h
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Fri Dec 09 02:32:21 2011 -0500
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Thu Dec 29 05:11:33 2011 -0500
     1.3 @@ -38,8 +38,11 @@
     1.4      {
     1.5          "opengles2",
     1.6          (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
     1.7 -        1,
     1.8 -        {SDL_PIXELFORMAT_ABGR8888},
     1.9 +        4,
    1.10 +        {SDL_PIXELFORMAT_ABGR8888,
    1.11 +        SDL_PIXELFORMAT_ARGB8888,
    1.12 +        SDL_PIXELFORMAT_RGB888,
    1.13 +        SDL_PIXELFORMAT_BGR888},
    1.14          0,
    1.15          0
    1.16      }
    1.17 @@ -111,7 +114,10 @@
    1.18  typedef enum
    1.19  {
    1.20      GLES2_IMAGESOURCE_SOLID,
    1.21 -    GLES2_IMAGESOURCE_TEXTURE
    1.22 +    GLES2_IMAGESOURCE_TEXTURE_ABGR,
    1.23 +    GLES2_IMAGESOURCE_TEXTURE_ARGB,
    1.24 +    GLES2_IMAGESOURCE_TEXTURE_RGB,
    1.25 +    GLES2_IMAGESOURCE_TEXTURE_BGR
    1.26  } GLES2_ImageSource;
    1.27  
    1.28  typedef struct GLES2_DriverContext
    1.29 @@ -272,6 +278,9 @@
    1.30      switch (texture->format)
    1.31      {
    1.32      case SDL_PIXELFORMAT_ABGR8888:
    1.33 +    case SDL_PIXELFORMAT_ARGB8888:
    1.34 +    case SDL_PIXELFORMAT_BGR888:
    1.35 +    case SDL_PIXELFORMAT_RGB888:
    1.36          format = GL_RGBA;
    1.37          type = GL_UNSIGNED_BYTE;
    1.38          break;
    1.39 @@ -635,7 +644,7 @@
    1.40      if (glGetError() != GL_NO_ERROR || !compileSuccessful)
    1.41      {
    1.42          char *info = NULL;
    1.43 -        int length;
    1.44 +        int length = 0;
    1.45  
    1.46          glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length);
    1.47          if (length > 0) {
    1.48 @@ -701,9 +710,20 @@
    1.49      case GLES2_IMAGESOURCE_SOLID:
    1.50          ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC;
    1.51          break;
    1.52 -    case GLES2_IMAGESOURCE_TEXTURE:
    1.53 -        ftype = GLES2_SHADER_FRAGMENT_TEXTURE_SRC;
    1.54 +    case GLES2_IMAGESOURCE_TEXTURE_ABGR:
    1.55 +        ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC;
    1.56 +            break;
    1.57 +    case GLES2_IMAGESOURCE_TEXTURE_ARGB:
    1.58 +        ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC;
    1.59          break;
    1.60 +    case GLES2_IMAGESOURCE_TEXTURE_RGB:
    1.61 +        ftype = GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC;
    1.62 +        break;
    1.63 +    case GLES2_IMAGESOURCE_TEXTURE_BGR:
    1.64 +        ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC;
    1.65 +        break;
    1.66 +    default:
    1.67 +        goto fault;
    1.68      }
    1.69  
    1.70      /* Load the requested shaders */
    1.71 @@ -1015,7 +1035,21 @@
    1.72  
    1.73      /* Activate an appropriate shader and set the projection matrix */
    1.74      blendMode = texture->blendMode;
    1.75 -    sourceType = GLES2_IMAGESOURCE_TEXTURE;
    1.76 +    switch (texture->format)
    1.77 +    {
    1.78 +        case SDL_PIXELFORMAT_ABGR8888:
    1.79 +            sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
    1.80 +            break;
    1.81 +        case SDL_PIXELFORMAT_ARGB8888:
    1.82 +            sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.83 +            break;
    1.84 +        case SDL_PIXELFORMAT_BGR888:
    1.85 +            sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
    1.86 +            break;
    1.87 +        case SDL_PIXELFORMAT_RGB888:
    1.88 +            sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
    1.89 +            break;
    1.90 +    }
    1.91      if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0)
    1.92          return -1;
    1.93  
     2.1 --- a/src/render/opengles2/SDL_shaders_gles2.c	Fri Dec 09 02:32:21 2011 -0500
     2.2 +++ b/src/render/opengles2/SDL_shaders_gles2.c	Thu Dec 29 05:11:33 2011 -0500
     2.3 @@ -55,7 +55,7 @@
     2.4      } \
     2.5  ";
     2.6  
     2.7 -static const Uint8 GLES2_FragmentSrc_TextureSrc_[] = " \
     2.8 +static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \
     2.9      precision mediump float; \
    2.10      uniform sampler2D u_texture; \
    2.11      uniform vec4 u_modulation; \
    2.12 @@ -68,6 +68,57 @@
    2.13      } \
    2.14  ";
    2.15  
    2.16 +// ARGB to ABGR conversion
    2.17 +static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
    2.18 +    precision mediump float; \
    2.19 +    uniform sampler2D u_texture; \
    2.20 +    uniform vec4 u_modulation; \
    2.21 +    varying vec2 v_texCoord; \
    2.22 +    \
    2.23 +    void main() \
    2.24 +    { \
    2.25 +        vec4 abgr = texture2D(u_texture, v_texCoord); \
    2.26 +        gl_FragColor = abgr; \
    2.27 +        gl_FragColor.r = abgr.b; \
    2.28 +        gl_FragColor.b = abgr.r; \
    2.29 +        gl_FragColor *= u_modulation; \
    2.30 +    } \
    2.31 +";
    2.32 +
    2.33 +// RGB to ABGR conversion
    2.34 +static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
    2.35 +    precision mediump float; \
    2.36 +    uniform sampler2D u_texture; \
    2.37 +    uniform vec4 u_modulation; \
    2.38 +    varying vec2 v_texCoord; \
    2.39 +    \
    2.40 +    void main() \
    2.41 +    { \
    2.42 +        vec4 abgr = texture2D(u_texture, v_texCoord); \
    2.43 +        gl_FragColor = abgr; \
    2.44 +        gl_FragColor.r = abgr.b; \
    2.45 +        gl_FragColor.b = abgr.r; \
    2.46 +        gl_FragColor.a = 1.0; \
    2.47 +        gl_FragColor *= u_modulation; \
    2.48 +    } \
    2.49 +";
    2.50 +
    2.51 +// BGR to ABGR conversion
    2.52 +static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
    2.53 +    precision mediump float; \
    2.54 +    uniform sampler2D u_texture; \
    2.55 +    uniform vec4 u_modulation; \
    2.56 +    varying vec2 v_texCoord; \
    2.57 +    \
    2.58 +    void main() \
    2.59 +    { \
    2.60 +        vec4 abgr = texture2D(u_texture, v_texCoord); \
    2.61 +        gl_FragColor = abgr; \
    2.62 +        gl_FragColor.a = 1.0; \
    2.63 +        gl_FragColor *= u_modulation; \
    2.64 +    } \
    2.65 +";
    2.66 +
    2.67  static const GLES2_ShaderInstance GLES2_VertexSrc_Default = {
    2.68      GL_VERTEX_SHADER,
    2.69      GLES2_SOURCE_SHADER,
    2.70 @@ -82,11 +133,32 @@
    2.71      GLES2_FragmentSrc_SolidSrc_
    2.72  };
    2.73  
    2.74 -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureSrc = {
    2.75 +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureABGRSrc = {
    2.76      GL_FRAGMENT_SHADER,
    2.77      GLES2_SOURCE_SHADER,
    2.78 -    sizeof(GLES2_FragmentSrc_TextureSrc_),
    2.79 -    GLES2_FragmentSrc_TextureSrc_
    2.80 +    sizeof(GLES2_FragmentSrc_TextureABGRSrc_),
    2.81 +    GLES2_FragmentSrc_TextureABGRSrc_
    2.82 +};
    2.83 +
    2.84 +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureARGBSrc = {
    2.85 +    GL_FRAGMENT_SHADER,
    2.86 +    GLES2_SOURCE_SHADER,
    2.87 +    sizeof(GLES2_FragmentSrc_TextureARGBSrc_),
    2.88 +    GLES2_FragmentSrc_TextureARGBSrc_
    2.89 +};
    2.90 +
    2.91 +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureRGBSrc = {
    2.92 +    GL_FRAGMENT_SHADER,
    2.93 +    GLES2_SOURCE_SHADER,
    2.94 +    sizeof(GLES2_FragmentSrc_TextureRGBSrc_),
    2.95 +    GLES2_FragmentSrc_TextureRGBSrc_
    2.96 +};
    2.97 +
    2.98 +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureBGRSrc = {
    2.99 +    GL_FRAGMENT_SHADER,
   2.100 +    GLES2_SOURCE_SHADER,
   2.101 +    sizeof(GLES2_FragmentSrc_TextureBGRSrc_),
   2.102 +    GLES2_FragmentSrc_TextureBGRSrc_
   2.103  };
   2.104  
   2.105  /*************************************************************************************************
   2.106 @@ -404,7 +476,11 @@
   2.107   *************************************************************************************************/
   2.108  
   2.109  static GLES2_Shader GLES2_VertexShader_Default = {
   2.110 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.111      2,
   2.112 +#else
   2.113 +    1,
   2.114 +#endif
   2.115      {
   2.116  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.117          &GLES2_VertexTegra_Default,
   2.118 @@ -414,7 +490,11 @@
   2.119  };
   2.120  
   2.121  static GLES2_Shader GLES2_FragmentShader_None_SolidSrc = {
   2.122 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.123      2,
   2.124 +#else
   2.125 +    1,
   2.126 +#endif
   2.127      {
   2.128  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.129          &GLES2_FragmentTegra_None_SolidSrc,
   2.130 @@ -424,7 +504,11 @@
   2.131  };
   2.132  
   2.133  static GLES2_Shader GLES2_FragmentShader_Alpha_SolidSrc = {
   2.134 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.135      2,
   2.136 +#else
   2.137 +    1,
   2.138 +#endif
   2.139      {
   2.140  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.141          &GLES2_FragmentTegra_Alpha_SolidSrc,
   2.142 @@ -434,7 +518,11 @@
   2.143  };
   2.144  
   2.145  static GLES2_Shader GLES2_FragmentShader_Additive_SolidSrc = {
   2.146 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.147      2,
   2.148 +#else
   2.149 +    1,
   2.150 +#endif
   2.151      {
   2.152  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.153          &GLES2_FragmentTegra_Additive_SolidSrc,
   2.154 @@ -444,7 +532,11 @@
   2.155  };
   2.156  
   2.157  static GLES2_Shader GLES2_FragmentShader_Modulated_SolidSrc = {
   2.158 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.159      2,
   2.160 +#else
   2.161 +    1,
   2.162 +#endif
   2.163      {
   2.164  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.165          &GLES2_FragmentTegra_Modulated_SolidSrc,
   2.166 @@ -453,43 +545,143 @@
   2.167      }
   2.168  };
   2.169  
   2.170 -static GLES2_Shader GLES2_FragmentShader_None_TextureSrc = {
   2.171 +static GLES2_Shader GLES2_FragmentShader_None_TextureABGRSrc = {
   2.172 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.173      2,
   2.174 +#else
   2.175 +    1,
   2.176 +#endif
   2.177      {
   2.178  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.179          &GLES2_FragmentTegra_None_TextureSrc,
   2.180  #endif
   2.181 -        &GLES2_FragmentSrc_TextureSrc
   2.182 +        &GLES2_FragmentSrc_TextureABGRSrc
   2.183      }
   2.184  };
   2.185  
   2.186 -static GLES2_Shader GLES2_FragmentShader_Alpha_TextureSrc = {
   2.187 +static GLES2_Shader GLES2_FragmentShader_Alpha_TextureABGRSrc = {
   2.188 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.189      2,
   2.190 +#else
   2.191 +    1,
   2.192 +#endif
   2.193      {
   2.194  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.195          &GLES2_FragmentTegra_Alpha_TextureSrc,
   2.196  #endif
   2.197 -        &GLES2_FragmentSrc_TextureSrc
   2.198 +        &GLES2_FragmentSrc_TextureABGRSrc
   2.199      }
   2.200  };
   2.201  
   2.202 -static GLES2_Shader GLES2_FragmentShader_Additive_TextureSrc = {
   2.203 +static GLES2_Shader GLES2_FragmentShader_Additive_TextureABGRSrc = {
   2.204 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.205      2,
   2.206 +#else
   2.207 +    1,
   2.208 +#endif
   2.209      {
   2.210  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.211          &GLES2_FragmentTegra_Additive_TextureSrc,
   2.212  #endif
   2.213 -        &GLES2_FragmentSrc_TextureSrc
   2.214 +        &GLES2_FragmentSrc_TextureABGRSrc
   2.215      }
   2.216  };
   2.217  
   2.218 -static GLES2_Shader GLES2_FragmentShader_Modulated_TextureSrc = {
   2.219 +static GLES2_Shader GLES2_FragmentShader_Modulated_TextureABGRSrc = {
   2.220 +#if GLES2_INCLUDE_NVIDIA_SHADERS
   2.221      2,
   2.222 +#else
   2.223 +    1,
   2.224 +#endif
   2.225      {
   2.226  #if GLES2_INCLUDE_NVIDIA_SHADERS
   2.227          &GLES2_FragmentTegra_Modulated_TextureSrc,
   2.228  #endif
   2.229 -        &GLES2_FragmentSrc_TextureSrc
   2.230 +        &GLES2_FragmentSrc_TextureABGRSrc
   2.231 +    }
   2.232 +};
   2.233 +
   2.234 +static GLES2_Shader GLES2_FragmentShader_None_TextureARGBSrc = {
   2.235 +    1,
   2.236 +    {
   2.237 +        &GLES2_FragmentSrc_TextureARGBSrc
   2.238 +    }
   2.239 +};
   2.240 +
   2.241 +static GLES2_Shader GLES2_FragmentShader_Alpha_TextureARGBSrc = {
   2.242 +    1,
   2.243 +    {
   2.244 +        &GLES2_FragmentSrc_TextureARGBSrc
   2.245 +    }
   2.246 +};
   2.247 +
   2.248 +static GLES2_Shader GLES2_FragmentShader_Additive_TextureARGBSrc = {
   2.249 +    1,
   2.250 +    {
   2.251 +        &GLES2_FragmentSrc_TextureARGBSrc
   2.252 +    }
   2.253 +};
   2.254 +
   2.255 +static GLES2_Shader GLES2_FragmentShader_Modulated_TextureARGBSrc = {
   2.256 +    1,
   2.257 +    {
   2.258 +        &GLES2_FragmentSrc_TextureARGBSrc
   2.259 +    }
   2.260 +};
   2.261 +
   2.262 +static GLES2_Shader GLES2_FragmentShader_None_TextureRGBSrc = {
   2.263 +    1,
   2.264 +    {
   2.265 +        &GLES2_FragmentSrc_TextureRGBSrc
   2.266 +    }
   2.267 +};
   2.268 +
   2.269 +static GLES2_Shader GLES2_FragmentShader_Alpha_TextureRGBSrc = {
   2.270 +    1,
   2.271 +    {
   2.272 +        &GLES2_FragmentSrc_TextureRGBSrc
   2.273 +    }
   2.274 +};
   2.275 +
   2.276 +static GLES2_Shader GLES2_FragmentShader_Additive_TextureRGBSrc = {
   2.277 +    1,
   2.278 +    {
   2.279 +        &GLES2_FragmentSrc_TextureRGBSrc
   2.280 +    }
   2.281 +};
   2.282 +
   2.283 +static GLES2_Shader GLES2_FragmentShader_Modulated_TextureRGBSrc = {
   2.284 +    1,
   2.285 +    {
   2.286 +        &GLES2_FragmentSrc_TextureRGBSrc
   2.287 +    }
   2.288 +};
   2.289 +
   2.290 +static GLES2_Shader GLES2_FragmentShader_None_TextureBGRSrc = {
   2.291 +    1,
   2.292 +    {
   2.293 +        &GLES2_FragmentSrc_TextureBGRSrc
   2.294 +    }
   2.295 +};
   2.296 +
   2.297 +static GLES2_Shader GLES2_FragmentShader_Alpha_TextureBGRSrc = {
   2.298 +    1,
   2.299 +    {
   2.300 +        &GLES2_FragmentSrc_TextureBGRSrc
   2.301 +    }
   2.302 +};
   2.303 +
   2.304 +static GLES2_Shader GLES2_FragmentShader_Additive_TextureBGRSrc = {
   2.305 +    1,
   2.306 +    {
   2.307 +        &GLES2_FragmentSrc_TextureBGRSrc
   2.308 +    }
   2.309 +};
   2.310 +
   2.311 +static GLES2_Shader GLES2_FragmentShader_Modulated_TextureBGRSrc = {
   2.312 +    1,
   2.313 +    {
   2.314 +        &GLES2_FragmentSrc_TextureBGRSrc
   2.315      }
   2.316  };
   2.317  
   2.318 @@ -504,33 +696,78 @@
   2.319      case GLES2_SHADER_VERTEX_DEFAULT:
   2.320          return &GLES2_VertexShader_Default;
   2.321      case GLES2_SHADER_FRAGMENT_SOLID_SRC:
   2.322 +    switch (blendMode)
   2.323 +    {
   2.324 +    case SDL_BLENDMODE_NONE:
   2.325 +        return &GLES2_FragmentShader_None_SolidSrc;
   2.326 +    case SDL_BLENDMODE_BLEND:
   2.327 +        return &GLES2_FragmentShader_Alpha_SolidSrc;
   2.328 +    case SDL_BLENDMODE_ADD:
   2.329 +        return &GLES2_FragmentShader_Additive_SolidSrc;
   2.330 +    case SDL_BLENDMODE_MOD:
   2.331 +        return &GLES2_FragmentShader_Modulated_SolidSrc;
   2.332 +    default:
   2.333 +        return NULL;
   2.334 +    }
   2.335 +    case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
   2.336          switch (blendMode)
   2.337 -        {
   2.338 +    {
   2.339          case SDL_BLENDMODE_NONE:
   2.340 -            return &GLES2_FragmentShader_None_SolidSrc;
   2.341 +            return &GLES2_FragmentShader_None_TextureABGRSrc;
   2.342          case SDL_BLENDMODE_BLEND:
   2.343 -            return &GLES2_FragmentShader_Alpha_SolidSrc;
   2.344 +            return &GLES2_FragmentShader_Alpha_TextureABGRSrc;
   2.345          case SDL_BLENDMODE_ADD:
   2.346 -            return &GLES2_FragmentShader_Additive_SolidSrc;
   2.347 +            return &GLES2_FragmentShader_Additive_TextureABGRSrc;
   2.348          case SDL_BLENDMODE_MOD:
   2.349 -            return &GLES2_FragmentShader_Modulated_SolidSrc;
   2.350 +            return &GLES2_FragmentShader_Modulated_TextureABGRSrc;
   2.351          default:
   2.352              return NULL;
   2.353 -        }
   2.354 -    case GLES2_SHADER_FRAGMENT_TEXTURE_SRC:
   2.355 +    }
   2.356 +    case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
   2.357          switch (blendMode)
   2.358 -        {
   2.359 +    {
   2.360          case SDL_BLENDMODE_NONE:
   2.361 -            return &GLES2_FragmentShader_None_TextureSrc;
   2.362 +            return &GLES2_FragmentShader_None_TextureARGBSrc;
   2.363          case SDL_BLENDMODE_BLEND:
   2.364 -            return &GLES2_FragmentShader_Alpha_TextureSrc;
   2.365 +            return &GLES2_FragmentShader_Alpha_TextureARGBSrc;
   2.366          case SDL_BLENDMODE_ADD:
   2.367 -            return &GLES2_FragmentShader_Additive_TextureSrc;
   2.368 +            return &GLES2_FragmentShader_Additive_TextureARGBSrc;
   2.369          case SDL_BLENDMODE_MOD:
   2.370 -            return &GLES2_FragmentShader_Modulated_TextureSrc;
   2.371 +            return &GLES2_FragmentShader_Modulated_TextureARGBSrc;
   2.372          default:
   2.373              return NULL;
   2.374 -        }
   2.375 +    }
   2.376 +        
   2.377 +    case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
   2.378 +        switch (blendMode)
   2.379 +    {
   2.380 +        case SDL_BLENDMODE_NONE:
   2.381 +            return &GLES2_FragmentShader_None_TextureRGBSrc;
   2.382 +        case SDL_BLENDMODE_BLEND:
   2.383 +            return &GLES2_FragmentShader_Alpha_TextureRGBSrc;
   2.384 +        case SDL_BLENDMODE_ADD:
   2.385 +            return &GLES2_FragmentShader_Additive_TextureRGBSrc;
   2.386 +        case SDL_BLENDMODE_MOD:
   2.387 +            return &GLES2_FragmentShader_Modulated_TextureRGBSrc;
   2.388 +        default:
   2.389 +            return NULL;
   2.390 +    }
   2.391 +        
   2.392 +    case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
   2.393 +        switch (blendMode)
   2.394 +    {
   2.395 +        case SDL_BLENDMODE_NONE:
   2.396 +            return &GLES2_FragmentShader_None_TextureBGRSrc;
   2.397 +        case SDL_BLENDMODE_BLEND:
   2.398 +            return &GLES2_FragmentShader_Alpha_TextureBGRSrc;
   2.399 +        case SDL_BLENDMODE_ADD:
   2.400 +            return &GLES2_FragmentShader_Additive_TextureBGRSrc;
   2.401 +        case SDL_BLENDMODE_MOD:
   2.402 +            return &GLES2_FragmentShader_Modulated_TextureBGRSrc;
   2.403 +        default:
   2.404 +            return NULL;
   2.405 +    }
   2.406 +        
   2.407      default:
   2.408          return NULL;
   2.409      }
     3.1 --- a/src/render/opengles2/SDL_shaders_gles2.h	Fri Dec 09 02:32:21 2011 -0500
     3.2 +++ b/src/render/opengles2/SDL_shaders_gles2.h	Thu Dec 29 05:11:33 2011 -0500
     3.3 @@ -43,7 +43,10 @@
     3.4  {
     3.5      GLES2_SHADER_VERTEX_DEFAULT,
     3.6      GLES2_SHADER_FRAGMENT_SOLID_SRC,
     3.7 -    GLES2_SHADER_FRAGMENT_TEXTURE_SRC
     3.8 +    GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC,
     3.9 +    GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC,
    3.10 +    GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC,
    3.11 +    GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC
    3.12  } GLES2_ShaderType;
    3.13  
    3.14  #define GLES2_SOURCE_SHADER (GLenum)-1