Mercurial > sdl-ios-xcode
comparison src/render/SDL_render.c @ 5160:657543cc92f9
Making the API simpler, removed the writepixels interface
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 03 Feb 2011 00:22:18 -0800 (2011-02-03) |
parents | 307ccc9c135e |
children | b3ccd1947786 |
comparison
equal
deleted
inserted
replaced
5159:307ccc9c135e | 5160:657543cc92f9 |
---|---|
1210 | 1210 |
1211 return renderer->RenderReadPixels(renderer, &real_rect, | 1211 return renderer->RenderReadPixels(renderer, &real_rect, |
1212 format, pixels, pitch); | 1212 format, pixels, pitch); |
1213 } | 1213 } |
1214 | 1214 |
1215 int | |
1216 SDL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, | |
1217 Uint32 format, const void * pixels, int pitch) | |
1218 { | |
1219 SDL_Window *window; | |
1220 SDL_Rect real_rect; | |
1221 | |
1222 CHECK_RENDERER_MAGIC(renderer, -1); | |
1223 | |
1224 if (!renderer->RenderWritePixels) { | |
1225 SDL_Unsupported(); | |
1226 return -1; | |
1227 } | |
1228 window = renderer->window; | |
1229 | |
1230 if (!format) { | |
1231 format = SDL_GetWindowPixelFormat(window); | |
1232 } | |
1233 | |
1234 real_rect.x = 0; | |
1235 real_rect.y = 0; | |
1236 SDL_GetWindowSize(window, &real_rect.w, &real_rect.h); | |
1237 if (rect) { | |
1238 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { | |
1239 return 0; | |
1240 } | |
1241 if (real_rect.y > rect->y) { | |
1242 pixels = (const Uint8 *)pixels + pitch * (real_rect.y - rect->y); | |
1243 } | |
1244 if (real_rect.x > rect->x) { | |
1245 int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window)); | |
1246 pixels = (const Uint8 *)pixels + bpp * (real_rect.x - rect->x); | |
1247 } | |
1248 } | |
1249 | |
1250 return renderer->RenderWritePixels(renderer, &real_rect, | |
1251 format, pixels, pitch); | |
1252 } | |
1253 | |
1254 void | 1215 void |
1255 SDL_RenderPresent(SDL_Renderer * renderer) | 1216 SDL_RenderPresent(SDL_Renderer * renderer) |
1256 { | 1217 { |
1257 CHECK_RENDERER_MAGIC(renderer, ); | 1218 CHECK_RENDERER_MAGIC(renderer, ); |
1258 | 1219 |