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 }

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 }

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

Referenced by SW_RunCommandQueue().

points
GLfixed GLfixed GLint GLint GLfixed points
Definition: SDL_opengl_glext.h:4558
SDL_DrawPoint
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
Definition: SDL_drawpoint.c:30
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1570
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8583
func
GLenum func
Definition: SDL_opengl_glext.h:657
SDL_CalculateDrawLineFunc
static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormat *fmt)
Definition: SDL_drawline.c:125
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1573
color
GLuint color
Definition: SDL_opengl_glext.h:1148
DrawLineFunc
void(* DrawLineFunc)(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color, SDL_bool draw_end)
Definition: SDL_drawline.c:120
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1573
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4583
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_TRUE
Definition: SDL_stdinc.h:164
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4583
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4583
SDL_IntersectRectAndLine
#define SDL_IntersectRectAndLine
Definition: SDL_dynapi_overrides.h:297
i
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