Mercurial > sdl-ios-xcode
comparison src/video/SDL_video.c @ 2901:133601e3b255
Added RenderPiont() API
Merged the drawing tests into a single test program
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 21 Dec 2008 17:39:41 +0000 |
parents | ca6499468250 |
children | aa6ba38c1714 |
comparison
equal
deleted
inserted
replaced
2900:3a9636c83849 | 2901:133601e3b255 |
---|---|
2068 } | 2068 } |
2069 *blendMode = renderer->blendMode; | 2069 *blendMode = renderer->blendMode; |
2070 return 0; | 2070 return 0; |
2071 } | 2071 } |
2072 | 2072 |
2073 | 2073 int |
2074 int | 2074 SDL_RenderPoint(int x, int y) |
2075 SDL_RenderFill(const SDL_Rect * rect) | |
2076 { | 2075 { |
2077 SDL_Renderer *renderer; | 2076 SDL_Renderer *renderer; |
2078 SDL_Window *window; | 2077 SDL_Window *window; |
2079 SDL_Rect real_rect; | 2078 SDL_Rect real_rect; |
2080 | 2079 |
2084 } | 2083 } |
2085 renderer = SDL_CurrentDisplay.current_renderer; | 2084 renderer = SDL_CurrentDisplay.current_renderer; |
2086 if (!renderer) { | 2085 if (!renderer) { |
2087 return -1; | 2086 return -1; |
2088 } | 2087 } |
2089 if (!renderer->RenderFill) { | 2088 if (!renderer->RenderPoint) { |
2090 SDL_Unsupported(); | 2089 SDL_Unsupported(); |
2091 return -1; | 2090 return -1; |
2092 } | 2091 } |
2093 window = SDL_GetWindowFromID(renderer->window); | 2092 window = SDL_GetWindowFromID(renderer->window); |
2094 real_rect.x = 0; | 2093 if (x < 0 || y < 0 || x >= window->w || y >= window->h) { |
2095 real_rect.y = 0; | 2094 return 0; |
2096 real_rect.w = window->w; | 2095 } |
2097 real_rect.h = window->h; | 2096 return renderer->RenderPoint(renderer, x, y); |
2098 if (rect) { | |
2099 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { | |
2100 return 0; | |
2101 } | |
2102 } | |
2103 return renderer->RenderFill(renderer, &real_rect); | |
2104 } | 2097 } |
2105 | 2098 |
2106 int | 2099 int |
2107 SDL_RenderLine(int x1, int y1, int x2, int y2) | 2100 SDL_RenderLine(int x1, int y1, int x2, int y2) |
2108 { | 2101 { |
2109 SDL_Renderer *renderer; | 2102 SDL_Renderer *renderer; |
2110 SDL_Window *window; | 2103 SDL_Window *window; |
2111 SDL_Rect real_rect; | 2104 SDL_Rect real_rect; |
2105 | |
2106 if (x1 == x2 && y1 == y2) { | |
2107 return SDL_RenderPoint(x1, y1); | |
2108 } | |
2112 | 2109 |
2113 if (!_this) { | 2110 if (!_this) { |
2114 SDL_UninitializedVideo(); | 2111 SDL_UninitializedVideo(); |
2115 return -1; | 2112 return -1; |
2116 } | 2113 } |
2134 return 0; | 2131 return 0; |
2135 } | 2132 } |
2136 } | 2133 } |
2137 #endif | 2134 #endif |
2138 return renderer->RenderLine(renderer, x1, y1, x2, y2); | 2135 return renderer->RenderLine(renderer, x1, y1, x2, y2); |
2136 } | |
2137 | |
2138 int | |
2139 SDL_RenderFill(const SDL_Rect * rect) | |
2140 { | |
2141 SDL_Renderer *renderer; | |
2142 SDL_Window *window; | |
2143 SDL_Rect real_rect; | |
2144 | |
2145 if (!_this) { | |
2146 SDL_UninitializedVideo(); | |
2147 return -1; | |
2148 } | |
2149 renderer = SDL_CurrentDisplay.current_renderer; | |
2150 if (!renderer) { | |
2151 return -1; | |
2152 } | |
2153 if (!renderer->RenderFill) { | |
2154 SDL_Unsupported(); | |
2155 return -1; | |
2156 } | |
2157 window = SDL_GetWindowFromID(renderer->window); | |
2158 real_rect.x = 0; | |
2159 real_rect.y = 0; | |
2160 real_rect.w = window->w; | |
2161 real_rect.h = window->h; | |
2162 if (rect) { | |
2163 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { | |
2164 return 0; | |
2165 } | |
2166 } | |
2167 return renderer->RenderFill(renderer, &real_rect); | |
2139 } | 2168 } |
2140 | 2169 |
2141 int | 2170 int |
2142 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, | 2171 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, |
2143 const SDL_Rect * dstrect) | 2172 const SDL_Rect * dstrect) |