Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
authorMike Gorchak <lestat@i.com.ua>
Wed, 03 Jun 2009 10:40:44 +0000
changeset 3163a252014ce27d
parent 3162 dc1eb82ffdaa
child 3164 c5b2884c26b4
Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
include/SDL_pixels.h
src/video/SDL_pixels.c
src/video/SDL_renderer_gles.c
     1.1 --- a/include/SDL_pixels.h	Wed Jun 03 04:37:27 2009 +0000
     1.2 +++ b/include/SDL_pixels.h	Wed Jun 03 10:40:44 2009 +0000
     1.3 @@ -158,6 +158,9 @@
     1.4      SDL_PIXELFORMAT_ARGB4444 =
     1.5          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
     1.6                                 SDL_PACKEDLAYOUT_4444, 16, 2),
     1.7 +    SDL_PIXELFORMAT_ABGR4444 =
     1.8 +        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
     1.9 +                               SDL_PACKEDLAYOUT_4444, 16, 2),
    1.10      SDL_PIXELFORMAT_ARGB1555 =
    1.11          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
    1.12                                 SDL_PACKEDLAYOUT_1555, 16, 2),
    1.13 @@ -167,6 +170,9 @@
    1.14      SDL_PIXELFORMAT_RGB565 =
    1.15          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
    1.16                                 SDL_PACKEDLAYOUT_565, 16, 2),
    1.17 +    SDL_PIXELFORMAT_BGR565 =
    1.18 +        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
    1.19 +                               SDL_PACKEDLAYOUT_565, 16, 2),
    1.20      SDL_PIXELFORMAT_RGB24 =
    1.21          SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
    1.22                                 24, 3),
     2.1 --- a/src/video/SDL_pixels.c	Wed Jun 03 04:37:27 2009 +0000
     2.2 +++ b/src/video/SDL_pixels.c	Wed Jun 03 10:40:44 2009 +0000
     2.3 @@ -72,6 +72,12 @@
     2.4          masks[2] = 0x000003E0;
     2.5          masks[3] = 0x0000001F;
     2.6          break;
     2.7 +    case SDL_PACKEDLAYOUT_5551:
     2.8 +        masks[0] = 0x0000F800;
     2.9 +        masks[1] = 0x000007C0;
    2.10 +        masks[2] = 0x0000003E;
    2.11 +        masks[3] = 0x00000001;
    2.12 +        break;
    2.13      case SDL_PACKEDLAYOUT_565:
    2.14          masks[0] = 0x00000000;
    2.15          masks[1] = 0x0000F800;
    2.16 @@ -90,6 +96,12 @@
    2.17          masks[2] = 0x000FFC00;
    2.18          masks[3] = 0x000003FF;
    2.19          break;
    2.20 +    case SDL_PACKEDLAYOUT_1010102:
    2.21 +        masks[0] = 0xFFC00000;
    2.22 +        masks[1] = 0x003FF000;
    2.23 +        masks[2] = 0x00000FFC;
    2.24 +        masks[3] = 0x00000003;
    2.25 +        break;
    2.26      default:
    2.27          /* Unknown layout */
    2.28          return SDL_FALSE;
    2.29 @@ -176,7 +188,12 @@
    2.30          break;
    2.31      case 16:
    2.32          switch (Rmask) {
    2.33 +        case 0x000F:
    2.34 +            return SDL_PIXELFORMAT_ABGR4444;
    2.35          case 0x001F:
    2.36 +            if (Gmask == 0x07E0) {
    2.37 +                return SDL_PIXELFORMAT_BGR565;
    2.38 +            }
    2.39              return SDL_PIXELFORMAT_ABGR1555;
    2.40          case 0x0F00:
    2.41              return SDL_PIXELFORMAT_ARGB4444;
     3.1 --- a/src/video/SDL_renderer_gles.c	Wed Jun 03 04:37:27 2009 +0000
     3.2 +++ b/src/video/SDL_renderer_gles.c	Wed Jun 03 10:40:44 2009 +0000
     3.3 @@ -30,7 +30,7 @@
     3.4  #include "SDL_rect_c.h"
     3.5  #include "SDL_yuv_sw_c.h"
     3.6  
     3.7 -#ifdef __QNXNTO__
     3.8 +#if defined(SDL_VIDEO_DRIVER_QNXGF) || defined(SDL_VIDEO_DRIVER_PHOTON)
     3.9  
    3.10  /* Empty function stub to get OpenGL ES 1.0 support without  */
    3.11  /* OpenGL ES extension GL_OES_draw_texture_supported         */
    3.12 @@ -110,9 +110,12 @@
    3.13       (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
    3.14        SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
    3.15       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
    3.16 -      SDL_TEXTURESCALEMODE_SLOW), 2,
    3.17 +      SDL_TEXTURESCALEMODE_SLOW), 5,
    3.18       {
    3.19        /* OpenGL ES 1.x supported formats list */
    3.20 +      SDL_PIXELFORMAT_ABGR4444,
    3.21 +      SDL_PIXELFORMAT_ABGR1555,
    3.22 +      SDL_PIXELFORMAT_BGR565,
    3.23        SDL_PIXELFORMAT_BGR24,
    3.24        SDL_PIXELFORMAT_ABGR8888},
    3.25       0,
    3.26 @@ -384,24 +387,21 @@
    3.27          format = GL_RGBA;
    3.28          type = GL_UNSIGNED_BYTE;
    3.29          break;
    3.30 -        /*
    3.31 -           These formats would be supported if SDL had the necessary pixel formats
    3.32 -           case SDL_PIXELFORMAT_BGR565:
    3.33 -           internalFormat = GL_RGB;
    3.34 -           format = GL_RGB;
    3.35 -           type = GL_UNSIGNED_SHORT_5_6_5;
    3.36 -           break;                       
    3.37 -           case SDL_PIXELFORMAT_ABGR5551:
    3.38 -           internalFormat = GL_RGBA;
    3.39 -           format = GL_RGBA;
    3.40 -           type = GL_UNSIGNED_SHORT_5_5_5_1;
    3.41 -           break;
    3.42 -           case SDL_PIXELFORMAT_ABGR4444:
    3.43 -           internalFormat = GL_RGBA;
    3.44 -           format = GL_RGBA;
    3.45 -           type = GL_UNSIGNED_SHORT_4_4_4_4;
    3.46 -           break;
    3.47 -         */
    3.48 +    case SDL_PIXELFORMAT_BGR565:
    3.49 +        internalFormat = GL_RGB;
    3.50 +        format = GL_RGB;
    3.51 +        type = GL_UNSIGNED_SHORT_5_6_5;
    3.52 +        break;
    3.53 +    case SDL_PIXELFORMAT_ABGR1555:
    3.54 +        internalFormat = GL_RGBA;
    3.55 +        format = GL_RGBA;
    3.56 +        type = GL_UNSIGNED_SHORT_5_5_5_1;
    3.57 +        break;
    3.58 +    case SDL_PIXELFORMAT_ABGR4444:
    3.59 +        internalFormat = GL_RGBA;
    3.60 +        format = GL_RGBA;
    3.61 +        type = GL_UNSIGNED_SHORT_4_4_4_4;
    3.62 +        break;
    3.63      default:
    3.64          SDL_SetError("Unsupported texture format");
    3.65          return -1;