comparison src/video/SDL_drawpoint.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
children 210e209b87cc
comparison
equal deleted inserted replaced
2900:3a9636c83849 2901:133601e3b255
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22 #include "SDL_config.h"
23
24 #include "SDL_draw.h"
25
26
27 int
28 SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
29 {
30 /* This function doesn't work on surfaces < 8 bpp */
31 if (dst->format->BitsPerPixel < 8) {
32 SDL_SetError("SDL_DrawLine(): Unsupported surface format");
33 return (-1);
34 }
35
36 /* Perform clipping */
37 if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
38 x >= (dst->clip_rect.x + dst->clip_rect.w) ||
39 y >= (dst->clip_rect.y + dst->clip_rect.h)) {
40 return 0;
41 }
42
43 switch (dst->format->BytesPerPixel) {
44 case 1:
45 DRAW_FASTSETPIXEL1(x, y);
46 break;
47 case 2:
48 DRAW_FASTSETPIXEL2(x, y);
49 break;
50 case 3:
51 SDL_Unsupported();
52 return -1;
53 case 4:
54 DRAW_FASTSETPIXEL4(x, y);
55 break;
56 }
57 return 0;
58 }
59
60 /* vi: set ts=4 sw=4 expandtab: */