Removed extra unneeded pixel formats, added support for VSYNC on other platforms besides Zune HD.
authorSam Lantinga <slouken@libsdl.org>
Sun, 06 Feb 2011 00:48:16 -0800
changeset 52021f2b17f42fd0
parent 5201 523409574510
child 5203 25ffd4e5255c
Removed extra unneeded pixel formats, added support for VSYNC on other platforms besides Zune HD.
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Sun Feb 06 00:00:13 2011 -0800
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sun Feb 06 00:48:16 2011 -0800
     1.3 @@ -46,40 +46,8 @@
     1.4      {
     1.5          "opengles2",
     1.6          (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
     1.7 -#if GLES2_ASSUME_BGRA
     1.8 -        11,
     1.9 -        {
    1.10 -            SDL_PIXELFORMAT_ABGR8888,
    1.11 -            SDL_PIXELFORMAT_ABGR4444,
    1.12 -            SDL_PIXELFORMAT_ABGR1555,
    1.13 -            SDL_PIXELFORMAT_BGR565,
    1.14 -            SDL_PIXELFORMAT_BGR24,
    1.15 -            SDL_PIXELFORMAT_ARGB8888,
    1.16 -            SDL_PIXELFORMAT_ARGB4444,
    1.17 -            SDL_PIXELFORMAT_ARGB1555,
    1.18 -            SDL_PIXELFORMAT_RGB565,
    1.19 -            SDL_PIXELFORMAT_RGB24
    1.20 -        },
    1.21 -#elif GLES2_ASSUME_BGRA8888
    1.22 -        7,
    1.23 -        {
    1.24 -            SDL_PIXELFORMAT_ABGR8888,
    1.25 -            SDL_PIXELFORMAT_ABGR4444,
    1.26 -            SDL_PIXELFORMAT_ABGR1555,
    1.27 -            SDL_PIXELFORMAT_BGR565,
    1.28 -            SDL_PIXELFORMAT_BGR24,
    1.29 -            SDL_PIXELFORMAT_ARGB8888
    1.30 -        },
    1.31 -#else
    1.32 -        6,
    1.33 -        {
    1.34 -            SDL_PIXELFORMAT_ABGR8888,
    1.35 -            SDL_PIXELFORMAT_ABGR4444,
    1.36 -            SDL_PIXELFORMAT_ABGR1555,
    1.37 -            SDL_PIXELFORMAT_BGR565,
    1.38 -            SDL_PIXELFORMAT_BGR24
    1.39 -        },
    1.40 -#endif
    1.41 +        1,
    1.42 +        {SDL_PIXELFORMAT_ABGR8888},
    1.43          0,
    1.44          0
    1.45      }
    1.46 @@ -248,9 +216,6 @@
    1.47   * Texture APIs                                                                                  *
    1.48   *************************************************************************************************/
    1.49  
    1.50 -#define GL_BGR_EXT  0x80E0
    1.51 -#define GL_BGRA_EXT 0x80E1
    1.52 -
    1.53  static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture);
    1.54  static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture);
    1.55  static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
    1.56 @@ -272,50 +237,10 @@
    1.57      /* Determine the corresponding GLES texture format params */
    1.58      switch (texture->format)
    1.59      {
    1.60 -    case SDL_PIXELFORMAT_BGR24:
    1.61 -        format = GL_RGB;
    1.62 -        type = GL_UNSIGNED_BYTE;
    1.63 -        break;
    1.64      case SDL_PIXELFORMAT_ABGR8888:
    1.65          format = GL_RGBA;
    1.66          type = GL_UNSIGNED_BYTE;
    1.67          break;
    1.68 -    case SDL_PIXELFORMAT_BGR565:
    1.69 -        format = GL_RGB;
    1.70 -        type = GL_UNSIGNED_SHORT_5_6_5;
    1.71 -        break;
    1.72 -    case SDL_PIXELFORMAT_ABGR1555:
    1.73 -        format = GL_RGBA;
    1.74 -        type = GL_UNSIGNED_SHORT_5_5_5_1;
    1.75 -        break;
    1.76 -    case SDL_PIXELFORMAT_ABGR4444:
    1.77 -        format = GL_RGBA;
    1.78 -        type = GL_UNSIGNED_SHORT_4_4_4_4;
    1.79 -        break;
    1.80 -#if GLES2_ASSUME_BGRA || GLES2_ASSUME_BGRA8888
    1.81 -    case SDL_PIXELFORMAT_ARGB8888:
    1.82 -        format = GL_BGRA_EXT;
    1.83 -        type = GL_UNSIGNED_BYTE;
    1.84 -        break;
    1.85 -#endif /* GLES2_ASSUME_BGRA || GLES2_ASSUME_BGRA8888 */
    1.86 -#if GLES2_ASSUME_BGRA
    1.87 -    case SDL_PIXELFORMAT_RGB24:
    1.88 -        format = GL_BGR_EXT;
    1.89 -        type = GL_UNSIGNED_BYTE;
    1.90 -        break;
    1.91 -    case SDL_PIXELFORMAT_RGB565:
    1.92 -        format = GL_BGR_EXT;
    1.93 -        type = GL_UNSIGNED_SHORT_5_6_5;
    1.94 -        break;
    1.95 -    case SDL_PIXELFORMAT_ARGB1555:
    1.96 -        format = GL_BGRA_EXT;
    1.97 -        type = GL_UNSIGNED_SHORT_5_5_5_1;
    1.98 -        break;
    1.99 -    case SDL_PIXELFORMAT_ARGB4444:
   1.100 -        format = GL_BGRA_EXT;
   1.101 -        type = GL_UNSIGNED_SHORT_4_4_4_4;
   1.102 -        break;
   1.103 -#endif /* GLES2_ASSUME_BGRA */
   1.104      default:
   1.105          SDL_SetError("Texture format not supported");
   1.106          return -1;
   1.107 @@ -1181,6 +1106,20 @@
   1.108          SDL_free(rdata);
   1.109          return NULL;
   1.110      }
   1.111 +    if (SDL_GL_MakeCurrent(window, rdata->context) < 0) {
   1.112 +        SDL_free(renderer);
   1.113 +        SDL_free(rdata);
   1.114 +        return NULL;
   1.115 +    }
   1.116 +
   1.117 +    if (flags & SDL_RENDERER_PRESENTVSYNC) {
   1.118 +        SDL_GL_SetSwapInterval(1);
   1.119 +    } else {
   1.120 +        SDL_GL_SetSwapInterval(0);
   1.121 +    }
   1.122 +    if (SDL_GL_GetSwapInterval() > 0) {
   1.123 +        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
   1.124 +    }
   1.125  
   1.126      /* Determine supported shader formats */
   1.127      /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */