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

◆ SDL_DrawLine()

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.

143{
145
146 if (!dst) {
147 return SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
148 }
149
151 if (!func) {
152 return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
153 }
154
155 /* Perform clipping */
156 /* FIXME: We don't actually want to clip, as it may change line slope */
157 if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
158 return 0;
159 }
160
161 func(dst, x1, y1, x2, y2, color, SDL_TRUE);
162 return 0;
163}
static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormat *fmt)
Definition: SDL_drawline.c:125
void(* DrawLineFunc)(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color, SDL_bool draw_end)
Definition: SDL_drawline.c:120
#define SDL_SetError
#define SDL_IntersectRectAndLine
GLenum func
GLfixed GLfixed GLfixed y2
GLfixed y1
GLuint color
GLuint GLfloat GLfloat GLfloat x1
GLfixed GLfixed x2
GLenum GLenum dst
@ SDL_TRUE
Definition: SDL_stdinc.h:164

References SDL_CalculateDrawLineFunc(), SDL_IntersectRectAndLine, SDL_SetError, and SDL_TRUE.

◆ SDL_DrawLines()

int SDL_DrawLines ( SDL_Surface dst,
const SDL_Point points,
int  count,
Uint32  color 
)

Definition at line 166 of file SDL_drawline.c.

168{
169 int i;
170 int x1, y1;
171 int x2, y2;
172 SDL_bool draw_end;
174
175 if (!dst) {
176 return SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
177 }
178
180 if (!func) {
181 return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
182 }
183
184 for (i = 1; i < count; ++i) {
185 x1 = points[i-1].x;
186 y1 = points[i-1].y;
187 x2 = points[i].x;
188 y2 = points[i].y;
189
190 /* Perform clipping */
191 /* FIXME: We don't actually want to clip, as it may change line slope */
192 if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
193 continue;
194 }
195
196 /* Draw the end if it was clipped */
197 draw_end = (x2 != points[i].x || y2 != points[i].y);
198
199 func(dst, x1, y1, x2, y2, color, draw_end);
200 }
201 if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
203 }
204 return 0;
205}
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
Definition: SDL_drawpoint.c:30
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLfixed GLfixed GLint GLint GLfixed points
SDL_bool
Definition: SDL_stdinc.h:162
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50

References i, SDL_CalculateDrawLineFunc(), SDL_DrawPoint(), SDL_IntersectRectAndLine, and SDL_SetError.

Referenced by SW_RunCommandQueue().