SDL  2.0
SDL_drawline.h File Reference
+ Include dependency graph for SDL_drawline.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int SDL_DrawLine (SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
int SDL_DrawLines (SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color)

Function Documentation

int SDL_DrawLine ( SDL_Surface dst,
int  x1,
int  y1,
int  x2,
int  y2,
Uint32  color 
)

Definition at line 142 of file SDL_drawline.c.

References SDL_Surface::clip_rect, SDL_Surface::format, SDL_CalculateDrawLineFunc(), SDL_IntersectRectAndLine, SDL_SetError, and SDL_TRUE.

{
if (!dst) {
return SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
}
if (!func) {
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
}
/* Perform clipping */
/* FIXME: We don't actually want to clip, as it may change line slope */
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
return 0;
}
func(dst, x1, y1, x2, y2, color, SDL_TRUE);
return 0;
}
int SDL_DrawLines ( SDL_Surface dst,
const SDL_Point points,
int  count,
Uint32  color 
)

Definition at line 166 of file SDL_drawline.c.

References SDL_Surface::clip_rect, SDL_Surface::format, i, SDL_CalculateDrawLineFunc(), SDL_DrawPoint(), SDL_IntersectRectAndLine, SDL_SetError, SDL_Point::x, and SDL_Point::y.

Referenced by SW_RenderDrawLines().

{
int i;
int x1, y1;
int x2, y2;
SDL_bool draw_end;
if (!dst) {
return SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
}
if (!func) {
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
}
for (i = 1; i < count; ++i) {
x1 = points[i-1].x;
y1 = points[i-1].y;
x2 = points[i].x;
y2 = points[i].y;
/* Perform clipping */
/* FIXME: We don't actually want to clip, as it may change line slope */
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
continue;
}
/* Draw the end if it was clipped */
draw_end = (x2 != points[i].x || y2 != points[i].y);
func(dst, x1, y1, x2, y2, color, draw_end);
}
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color);
}
return 0;
}