Mercurial > sdl-ios-xcode
comparison test/testsprite2.c @ 3596:f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Renamed SDL_RenderPoint() and SDL_RenderLine() to SDL_RenderDrawPoint() and SDL_RenderDrawLine().
Added API for rectangle drawing (as opposed to filling)
Added placeholder API functions for circles and ellipses ... I'm not sure whether these will stay.
Optimized software line drawing quite a bit.
Added support for Wu's anti-aliased line drawing, currently disabled by default.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 23 Dec 2009 01:55:00 +0000 |
parents | 5543db4239e6 |
children | 64ce267332c6 |
comparison
equal
deleted
inserted
replaced
3595:b7c6828d4039 | 3596:f638ded38b8a |
---|---|
137 SDL_SetTextureAlphaMod(sprite, (Uint8) current_alpha); | 137 SDL_SetTextureAlphaMod(sprite, (Uint8) current_alpha); |
138 } | 138 } |
139 | 139 |
140 /* Draw a gray background */ | 140 /* Draw a gray background */ |
141 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); | 141 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); |
142 SDL_RenderRect(NULL); | 142 SDL_RenderClear(); |
143 | 143 |
144 /* Test points */ | 144 /* Test points */ |
145 SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF); | 145 SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF); |
146 SDL_RenderPoint(0, 0); | 146 SDL_RenderDrawPoint(0, 0); |
147 SDL_RenderPoint(window_w-1, 0); | 147 SDL_RenderDrawPoint(window_w-1, 0); |
148 SDL_RenderPoint(0, window_h-1); | 148 SDL_RenderDrawPoint(0, window_h-1); |
149 SDL_RenderPoint(window_w-1, window_h-1); | 149 SDL_RenderDrawPoint(window_w-1, window_h-1); |
150 | 150 |
151 /* Test horizontal and vertical lines */ | 151 /* Test horizontal and vertical lines */ |
152 SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF); | 152 SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF); |
153 SDL_RenderLine(1, 0, window_w-2, 0); | 153 SDL_RenderDrawLine(1, 0, window_w-2, 0); |
154 SDL_RenderLine(1, window_h-1, window_w-2, window_h-1); | 154 SDL_RenderDrawLine(1, window_h-1, window_w-2, window_h-1); |
155 SDL_RenderLine(0, 1, 0, window_h-2); | 155 SDL_RenderDrawLine(0, 1, 0, window_h-2); |
156 SDL_RenderLine(window_w-1, 1, window_w-1, window_h-2); | 156 SDL_RenderDrawLine(window_w-1, 1, window_w-1, window_h-2); |
157 | 157 |
158 /* Test fill and copy */ | 158 /* Test fill and copy */ |
159 SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF); | 159 SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF); |
160 temp.x = 1; | 160 temp.x = 1; |
161 temp.y = 1; | 161 temp.y = 1; |
162 temp.w = sprite_w; | 162 temp.w = sprite_w; |
163 temp.h = sprite_h; | 163 temp.h = sprite_h; |
164 SDL_RenderRect(&temp); | 164 SDL_RenderFillRect(&temp); |
165 SDL_RenderCopy(sprite, NULL, &temp); | 165 SDL_RenderCopy(sprite, NULL, &temp); |
166 temp.x = window_w-sprite_w-1; | 166 temp.x = window_w-sprite_w-1; |
167 temp.y = 1; | 167 temp.y = 1; |
168 temp.w = sprite_w; | 168 temp.w = sprite_w; |
169 temp.h = sprite_h; | 169 temp.h = sprite_h; |
170 SDL_RenderRect(&temp); | 170 SDL_RenderFillRect(&temp); |
171 SDL_RenderCopy(sprite, NULL, &temp); | 171 SDL_RenderCopy(sprite, NULL, &temp); |
172 temp.x = 1; | 172 temp.x = 1; |
173 temp.y = window_h-sprite_h-1; | 173 temp.y = window_h-sprite_h-1; |
174 temp.w = sprite_w; | 174 temp.w = sprite_w; |
175 temp.h = sprite_h; | 175 temp.h = sprite_h; |
176 SDL_RenderRect(&temp); | 176 SDL_RenderFillRect(&temp); |
177 SDL_RenderCopy(sprite, NULL, &temp); | 177 SDL_RenderCopy(sprite, NULL, &temp); |
178 temp.x = window_w-sprite_w-1; | 178 temp.x = window_w-sprite_w-1; |
179 temp.y = window_h-sprite_h-1; | 179 temp.y = window_h-sprite_h-1; |
180 temp.w = sprite_w; | 180 temp.w = sprite_w; |
181 temp.h = sprite_h; | 181 temp.h = sprite_h; |
182 SDL_RenderRect(&temp); | 182 SDL_RenderFillRect(&temp); |
183 SDL_RenderCopy(sprite, NULL, &temp); | 183 SDL_RenderCopy(sprite, NULL, &temp); |
184 | 184 |
185 /* Test diagonal lines */ | 185 /* Test diagonal lines */ |
186 SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF); | 186 SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF); |
187 SDL_RenderLine(sprite_w, sprite_h, | 187 SDL_RenderDrawLine(sprite_w, sprite_h, |
188 window_w-sprite_w-2, window_h-sprite_h-2); | 188 window_w-sprite_w-2, window_h-sprite_h-2); |
189 SDL_RenderLine(window_w-sprite_w-2, sprite_h, | 189 SDL_RenderDrawLine(window_w-sprite_w-2, sprite_h, |
190 sprite_w, window_h-sprite_h-2); | 190 sprite_w, window_h-sprite_h-2); |
191 | 191 |
192 /* Move the sprite, bounce at the wall, and draw */ | 192 /* Move the sprite, bounce at the wall, and draw */ |
193 n = 0; | 193 n = 0; |
194 for (i = 0; i < num_sprites; ++i) { | 194 for (i = 0; i < num_sprites; ++i) { |
195 position = &positions[i]; | 195 position = &positions[i]; |
300 quit(2); | 300 quit(2); |
301 } | 301 } |
302 for (i = 0; i < state->num_windows; ++i) { | 302 for (i = 0; i < state->num_windows; ++i) { |
303 SDL_SelectRenderer(state->windows[i]); | 303 SDL_SelectRenderer(state->windows[i]); |
304 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); | 304 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); |
305 SDL_RenderRect(NULL); | 305 SDL_RenderClear(); |
306 } | 306 } |
307 if (LoadSprite("icon.bmp") < 0) { | 307 if (LoadSprite("icon.bmp") < 0) { |
308 quit(2); | 308 quit(2); |
309 } | 309 } |
310 | 310 |
346 case SDL_WINDOWEVENT: | 346 case SDL_WINDOWEVENT: |
347 switch (event.window.event) { | 347 switch (event.window.event) { |
348 case SDL_WINDOWEVENT_EXPOSED: | 348 case SDL_WINDOWEVENT_EXPOSED: |
349 SDL_SelectRenderer(event.window.windowID); | 349 SDL_SelectRenderer(event.window.windowID); |
350 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); | 350 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); |
351 SDL_RenderRect(NULL); | 351 SDL_RenderClear(); |
352 break; | 352 break; |
353 } | 353 } |
354 break; | 354 break; |
355 default: | 355 default: |
356 break; | 356 break; |