Mercurial > sdl-ios-xcode
comparison src/video/SDL_video.c @ 5151:5429daf5e3f9
The DrawRect API is implemented using lines
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 20:50:04 -0800 |
parents | ad50b3db78bd |
children | be02be2ea897 |
comparison
equal
deleted
inserted
replaced
5150:ad50b3db78bd | 5151:5429daf5e3f9 |
---|---|
2317 } | 2317 } |
2318 | 2318 |
2319 int | 2319 int |
2320 SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect) | 2320 SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect) |
2321 { | 2321 { |
2322 return SDL_RenderDrawRects(renderer, &rect, 1); | 2322 SDL_Rect full_rect; |
2323 SDL_Point points[5]; | |
2324 | |
2325 CHECK_RENDERER_MAGIC(renderer, -1); | |
2326 | |
2327 /* If 'rect' == NULL, then outline the whole surface */ | |
2328 if (!rect) { | |
2329 SDL_Window *window = renderer->window; | |
2330 | |
2331 full_rect.x = 0; | |
2332 full_rect.y = 0; | |
2333 full_rect.w = window->w; | |
2334 full_rect.h = window->h; | |
2335 rect = &full_rect; | |
2336 } | |
2337 | |
2338 points[0].x = rect->x; | |
2339 points[0].y = rect->y; | |
2340 points[1].x = rect->x+rect->w-1; | |
2341 points[1].y = rect->y; | |
2342 points[2].x = rect->x+rect->w-1; | |
2343 points[2].y = rect->y+rect->h-1; | |
2344 points[3].x = rect->x; | |
2345 points[3].y = rect->y+rect->h-1; | |
2346 points[4].x = rect->x; | |
2347 points[4].y = rect->y; | |
2348 return SDL_RenderDrawLines(renderer, points, 5); | |
2323 } | 2349 } |
2324 | 2350 |
2325 int | 2351 int |
2326 SDL_RenderDrawRects(SDL_Renderer * renderer, | 2352 SDL_RenderDrawRects(SDL_Renderer * renderer, |
2327 const SDL_Rect ** rects, int count) | 2353 const SDL_Rect ** rects, int count) |
2338 return 0; | 2364 return 0; |
2339 } | 2365 } |
2340 | 2366 |
2341 /* Check for NULL rect, which means fill entire window */ | 2367 /* Check for NULL rect, which means fill entire window */ |
2342 for (i = 0; i < count; ++i) { | 2368 for (i = 0; i < count; ++i) { |
2343 if (rects[i] == NULL) { | 2369 if (SDL_RenderDrawRect(renderer, rects[i]) < 0) { |
2344 SDL_Window *window = renderer->window; | 2370 return -1; |
2345 SDL_Rect full_rect; | 2371 } |
2346 const SDL_Rect *rect; | 2372 } |
2347 | 2373 return 0; |
2348 full_rect.x = 0; | |
2349 full_rect.y = 0; | |
2350 full_rect.w = window->w; | |
2351 full_rect.h = window->h; | |
2352 rect = &full_rect; | |
2353 return renderer->RenderDrawRects(renderer, &rect, 1); | |
2354 } | |
2355 } | |
2356 return renderer->RenderDrawRects(renderer, rects, count); | |
2357 } | 2374 } |
2358 | 2375 |
2359 int | 2376 int |
2360 SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect) | 2377 SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect) |
2361 { | 2378 { |