Mercurial > sdl-ios-xcode
diff src/render/opengles2/SDL_render_gles2.c @ 5205:1f2b17f42fd0
Removed extra unneeded pixel formats, added support for VSYNC on other platforms besides Zune HD.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 06 Feb 2011 00:48:16 -0800 |
parents | 523409574510 |
children | daa5463466c5 |
line wrap: on
line diff
--- a/src/render/opengles2/SDL_render_gles2.c Sun Feb 06 00:00:13 2011 -0800 +++ b/src/render/opengles2/SDL_render_gles2.c Sun Feb 06 00:48:16 2011 -0800 @@ -46,40 +46,8 @@ { "opengles2", (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), -#if GLES2_ASSUME_BGRA - 11, - { - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_ABGR4444, - SDL_PIXELFORMAT_ABGR1555, - SDL_PIXELFORMAT_BGR565, - SDL_PIXELFORMAT_BGR24, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB24 - }, -#elif GLES2_ASSUME_BGRA8888 - 7, - { - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_ABGR4444, - SDL_PIXELFORMAT_ABGR1555, - SDL_PIXELFORMAT_BGR565, - SDL_PIXELFORMAT_BGR24, - SDL_PIXELFORMAT_ARGB8888 - }, -#else - 6, - { - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_ABGR4444, - SDL_PIXELFORMAT_ABGR1555, - SDL_PIXELFORMAT_BGR565, - SDL_PIXELFORMAT_BGR24 - }, -#endif + 1, + {SDL_PIXELFORMAT_ABGR8888}, 0, 0 } @@ -248,9 +216,6 @@ * Texture APIs * *************************************************************************************************/ -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 - static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, @@ -272,50 +237,10 @@ /* Determine the corresponding GLES texture format params */ switch (texture->format) { - case SDL_PIXELFORMAT_BGR24: - format = GL_RGB; - type = GL_UNSIGNED_BYTE; - break; case SDL_PIXELFORMAT_ABGR8888: format = GL_RGBA; type = GL_UNSIGNED_BYTE; break; - case SDL_PIXELFORMAT_BGR565: - format = GL_RGB; - type = GL_UNSIGNED_SHORT_5_6_5; - break; - case SDL_PIXELFORMAT_ABGR1555: - format = GL_RGBA; - type = GL_UNSIGNED_SHORT_5_5_5_1; - break; - case SDL_PIXELFORMAT_ABGR4444: - format = GL_RGBA; - type = GL_UNSIGNED_SHORT_4_4_4_4; - break; -#if GLES2_ASSUME_BGRA || GLES2_ASSUME_BGRA8888 - case SDL_PIXELFORMAT_ARGB8888: - format = GL_BGRA_EXT; - type = GL_UNSIGNED_BYTE; - break; -#endif /* GLES2_ASSUME_BGRA || GLES2_ASSUME_BGRA8888 */ -#if GLES2_ASSUME_BGRA - case SDL_PIXELFORMAT_RGB24: - format = GL_BGR_EXT; - type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_RGB565: - format = GL_BGR_EXT; - type = GL_UNSIGNED_SHORT_5_6_5; - break; - case SDL_PIXELFORMAT_ARGB1555: - format = GL_BGRA_EXT; - type = GL_UNSIGNED_SHORT_5_5_5_1; - break; - case SDL_PIXELFORMAT_ARGB4444: - format = GL_BGRA_EXT; - type = GL_UNSIGNED_SHORT_4_4_4_4; - break; -#endif /* GLES2_ASSUME_BGRA */ default: SDL_SetError("Texture format not supported"); return -1; @@ -1181,6 +1106,20 @@ SDL_free(rdata); return NULL; } + if (SDL_GL_MakeCurrent(window, rdata->context) < 0) { + SDL_free(renderer); + SDL_free(rdata); + return NULL; + } + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + if (SDL_GL_GetSwapInterval() > 0) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } /* Determine supported shader formats */ /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */