Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
5204:523409574510 | 5205:1f2b17f42fd0 |
---|---|
44 SDL_RenderDriver GLES2_RenderDriver = { | 44 SDL_RenderDriver GLES2_RenderDriver = { |
45 GLES2_CreateRenderer, | 45 GLES2_CreateRenderer, |
46 { | 46 { |
47 "opengles2", | 47 "opengles2", |
48 (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), | 48 (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), |
49 #if GLES2_ASSUME_BGRA | 49 1, |
50 11, | 50 {SDL_PIXELFORMAT_ABGR8888}, |
51 { | |
52 SDL_PIXELFORMAT_ABGR8888, | |
53 SDL_PIXELFORMAT_ABGR4444, | |
54 SDL_PIXELFORMAT_ABGR1555, | |
55 SDL_PIXELFORMAT_BGR565, | |
56 SDL_PIXELFORMAT_BGR24, | |
57 SDL_PIXELFORMAT_ARGB8888, | |
58 SDL_PIXELFORMAT_ARGB4444, | |
59 SDL_PIXELFORMAT_ARGB1555, | |
60 SDL_PIXELFORMAT_RGB565, | |
61 SDL_PIXELFORMAT_RGB24 | |
62 }, | |
63 #elif GLES2_ASSUME_BGRA8888 | |
64 7, | |
65 { | |
66 SDL_PIXELFORMAT_ABGR8888, | |
67 SDL_PIXELFORMAT_ABGR4444, | |
68 SDL_PIXELFORMAT_ABGR1555, | |
69 SDL_PIXELFORMAT_BGR565, | |
70 SDL_PIXELFORMAT_BGR24, | |
71 SDL_PIXELFORMAT_ARGB8888 | |
72 }, | |
73 #else | |
74 6, | |
75 { | |
76 SDL_PIXELFORMAT_ABGR8888, | |
77 SDL_PIXELFORMAT_ABGR4444, | |
78 SDL_PIXELFORMAT_ABGR1555, | |
79 SDL_PIXELFORMAT_BGR565, | |
80 SDL_PIXELFORMAT_BGR24 | |
81 }, | |
82 #endif | |
83 0, | 51 0, |
84 0 | 52 0 |
85 } | 53 } |
86 }; | 54 }; |
87 | 55 |
246 | 214 |
247 /************************************************************************************************* | 215 /************************************************************************************************* |
248 * Texture APIs * | 216 * Texture APIs * |
249 *************************************************************************************************/ | 217 *************************************************************************************************/ |
250 | 218 |
251 #define GL_BGR_EXT 0x80E0 | |
252 #define GL_BGRA_EXT 0x80E1 | |
253 | |
254 static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); | 219 static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); |
255 static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); | 220 static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); |
256 static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, | 221 static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, |
257 void **pixels, int *pitch); | 222 void **pixels, int *pitch); |
258 static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture); | 223 static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture); |
270 GLES2_ActivateRenderer(renderer); | 235 GLES2_ActivateRenderer(renderer); |
271 | 236 |
272 /* Determine the corresponding GLES texture format params */ | 237 /* Determine the corresponding GLES texture format params */ |
273 switch (texture->format) | 238 switch (texture->format) |
274 { | 239 { |
275 case SDL_PIXELFORMAT_BGR24: | |
276 format = GL_RGB; | |
277 type = GL_UNSIGNED_BYTE; | |
278 break; | |
279 case SDL_PIXELFORMAT_ABGR8888: | 240 case SDL_PIXELFORMAT_ABGR8888: |
280 format = GL_RGBA; | 241 format = GL_RGBA; |
281 type = GL_UNSIGNED_BYTE; | 242 type = GL_UNSIGNED_BYTE; |
282 break; | 243 break; |
283 case SDL_PIXELFORMAT_BGR565: | |
284 format = GL_RGB; | |
285 type = GL_UNSIGNED_SHORT_5_6_5; | |
286 break; | |
287 case SDL_PIXELFORMAT_ABGR1555: | |
288 format = GL_RGBA; | |
289 type = GL_UNSIGNED_SHORT_5_5_5_1; | |
290 break; | |
291 case SDL_PIXELFORMAT_ABGR4444: | |
292 format = GL_RGBA; | |
293 type = GL_UNSIGNED_SHORT_4_4_4_4; | |
294 break; | |
295 #if GLES2_ASSUME_BGRA || GLES2_ASSUME_BGRA8888 | |
296 case SDL_PIXELFORMAT_ARGB8888: | |
297 format = GL_BGRA_EXT; | |
298 type = GL_UNSIGNED_BYTE; | |
299 break; | |
300 #endif /* GLES2_ASSUME_BGRA || GLES2_ASSUME_BGRA8888 */ | |
301 #if GLES2_ASSUME_BGRA | |
302 case SDL_PIXELFORMAT_RGB24: | |
303 format = GL_BGR_EXT; | |
304 type = GL_UNSIGNED_BYTE; | |
305 break; | |
306 case SDL_PIXELFORMAT_RGB565: | |
307 format = GL_BGR_EXT; | |
308 type = GL_UNSIGNED_SHORT_5_6_5; | |
309 break; | |
310 case SDL_PIXELFORMAT_ARGB1555: | |
311 format = GL_BGRA_EXT; | |
312 type = GL_UNSIGNED_SHORT_5_5_5_1; | |
313 break; | |
314 case SDL_PIXELFORMAT_ARGB4444: | |
315 format = GL_BGRA_EXT; | |
316 type = GL_UNSIGNED_SHORT_4_4_4_4; | |
317 break; | |
318 #endif /* GLES2_ASSUME_BGRA */ | |
319 default: | 244 default: |
320 SDL_SetError("Texture format not supported"); | 245 SDL_SetError("Texture format not supported"); |
321 return -1; | 246 return -1; |
322 } | 247 } |
323 | 248 |
1179 { | 1104 { |
1180 SDL_free(renderer); | 1105 SDL_free(renderer); |
1181 SDL_free(rdata); | 1106 SDL_free(rdata); |
1182 return NULL; | 1107 return NULL; |
1183 } | 1108 } |
1109 if (SDL_GL_MakeCurrent(window, rdata->context) < 0) { | |
1110 SDL_free(renderer); | |
1111 SDL_free(rdata); | |
1112 return NULL; | |
1113 } | |
1114 | |
1115 if (flags & SDL_RENDERER_PRESENTVSYNC) { | |
1116 SDL_GL_SetSwapInterval(1); | |
1117 } else { | |
1118 SDL_GL_SetSwapInterval(0); | |
1119 } | |
1120 if (SDL_GL_GetSwapInterval() > 0) { | |
1121 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; | |
1122 } | |
1184 | 1123 |
1185 /* Determine supported shader formats */ | 1124 /* Determine supported shader formats */ |
1186 /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */ | 1125 /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */ |
1187 glGetError(); | 1126 glGetError(); |
1188 #ifdef ZUNE_HD | 1127 #ifdef ZUNE_HD |