comparison src/video/SDL_drawline.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 3a9636c83849
children 3da0bb421d83
comparison
equal deleted inserted replaced
2900:3a9636c83849 2901:133601e3b255
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 #include "SDL_draw.h" 24 #include "SDL_draw.h"
25 25
26 #define SETPIXEL(x, y, type, bpp, color) \
27 *(type *)(dst->pixels + y * dst->pitch + x * bpp) = (type) color
28 26
29 #define SETPIXEL1(x, y) SETPIXEL(x, y, Uint8, 1, color); 27 int
30 #define SETPIXEL2(x, y) SETPIXEL(x, y, Uint16, 2, color);
31 #define SETPIXEL4(x, y) SETPIXEL(x, y, Uint32, 4, color);
32
33 SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color) 28 SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
34 { 29 {
35 /* This function doesn't work on surfaces < 8 bpp */ 30 /* This function doesn't work on surfaces < 8 bpp */
36 if (dst->format->BitsPerPixel < 8) { 31 if (dst->format->BitsPerPixel < 8) {
37 SDL_SetError("SDL_DrawLine(): Unsupported surface format"); 32 SDL_SetError("SDL_DrawLine(): Unsupported surface format");
45 } 40 }
46 */ 41 */
47 42
48 switch (dst->format->BytesPerPixel) { 43 switch (dst->format->BytesPerPixel) {
49 case 1: 44 case 1:
50 DRAWLINE(x1, y1, x2, y2, SETPIXEL1); 45 DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL1);
51 break; 46 break;
52 case 2: 47 case 2:
53 DRAWLINE(x1, y1, x2, y2, SETPIXEL2); 48 DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL2);
54 break; 49 break;
55 case 3: 50 case 3:
56 SDL_Unsupported(); 51 SDL_Unsupported();
57 return -1; 52 return -1;
58 case 4: 53 case 4:
59 DRAWLINE(x1, y1, x2, y2, SETPIXEL4); 54 DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL4);
60 break; 55 break;
61 } 56 }
62 return 0; 57 return 0;
63 } 58 }
64 59