Mercurial > sdl-ios-xcode
comparison src/video/SDL_draw.h @ 3594:c8bed77b0386
Added SDL_DrawRect(), SDL_DrawRects(), SDL_BlendRect() and SDL_BlendRects()
Fixed line drawing so when blending a sequence of lines there are no overlapping pixels drawn.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 18 Dec 2009 07:41:59 +0000 |
parents | b931bcfd94a0 |
children | f638ded38b8a |
comparison
equal
deleted
inserted
replaced
3593:b931bcfd94a0 | 3594:c8bed77b0386 |
---|---|
281 * Define line drawing macro | 281 * Define line drawing macro |
282 */ | 282 */ |
283 | 283 |
284 #define ABS(_x) ((_x) < 0 ? -(_x) : (_x)) | 284 #define ABS(_x) ((_x) < 0 ? -(_x) : (_x)) |
285 | 285 |
286 #define BRESENHAM(x1, y1, x2, y2, op) \ | 286 #define BRESENHAM(x1, y1, x2, y2, op, draw_end) \ |
287 { \ | 287 { \ |
288 int i, deltax, deltay, numpixels; \ | 288 int i, deltax, deltay, numpixels; \ |
289 int d, dinc1, dinc2; \ | 289 int d, dinc1, dinc2; \ |
290 int x, xinc1, xinc2; \ | 290 int x, xinc1, xinc2; \ |
291 int y, yinc1, yinc2; \ | 291 int y, yinc1, yinc2; \ |
323 } \ | 323 } \ |
324 \ | 324 \ |
325 x = x1; \ | 325 x = x1; \ |
326 y = y1; \ | 326 y = y1; \ |
327 \ | 327 \ |
328 if (!draw_end) { \ | |
329 --numpixels; \ | |
330 } \ | |
328 for (i = 0; i < numpixels; ++i) { \ | 331 for (i = 0; i < numpixels; ++i) { \ |
329 op(x, y); \ | 332 op(x, y); \ |
330 if (d < 0) { \ | 333 if (d < 0) { \ |
331 d += dinc1; \ | 334 d += dinc1; \ |
332 x += xinc1; \ | 335 x += xinc1; \ |
336 x += xinc2; \ | 339 x += xinc2; \ |
337 y += yinc2; \ | 340 y += yinc2; \ |
338 } \ | 341 } \ |
339 } \ | 342 } \ |
340 } | 343 } |
341 #define DRAWLINE(x0, y0, x1, y1, op) BRESENHAM(x0, y0, x1, y1, op) | 344 #define DRAWLINE BRESENHAM |
342 | 345 |
343 /* | 346 /* |
344 * Define draw rect macro | 347 * Define draw rect macro |
348 * (not tested, this level of optimization not needed ... yet?) | |
345 */ | 349 */ |
346 #define DRAWRECT(type, op) \ | 350 #define DRAWRECT(type, op) \ |
347 do { \ | 351 do { \ |
348 int width = rect->w; \ | 352 int width = rect->w; \ |
349 int height = rect->h; \ | 353 int height = rect->h; \ |