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