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

Go to the source code of this file.

Functions

int SDL_BlendLine (SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
int SDL_BlendLines (SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 

Function Documentation

◆ SDL_BlendLine()

int SDL_BlendLine ( SDL_Surface dst,
int  x1,
int  y1,
int  x2,
int  y2,
SDL_BlendMode  blendMode,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

Definition at line 708 of file SDL_blendline.c.

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

710 {
712 
713  if (!dst) {
714  return SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
715  }
716 
717  func = SDL_CalculateBlendLineFunc(dst->format);
718  if (!func) {
719  return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
720  }
721 
722  /* Perform clipping */
723  /* FIXME: We don't actually want to clip, as it may change line slope */
724  if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
725  return 0;
726  }
727 
728  func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE);
729  return 0;
730 }
void(* BlendLineFunc)(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_bool draw_end)
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
GLuint GLfloat GLfloat GLfloat x1
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt)
GLfixed GLfixed GLfixed y2
GLfixed GLfixed x2
GLfixed y1
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_Rect clip_rect
Definition: SDL_surface.h:85
SDL_PixelFormat * format
Definition: SDL_surface.h:72
#define SDL_SetError
GLenum func
#define SDL_IntersectRectAndLine
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g
GLboolean GLboolean GLboolean b

◆ SDL_BlendLines()

int SDL_BlendLines ( SDL_Surface dst,
const SDL_Point points,
int  count,
SDL_BlendMode  blendMode,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

Definition at line 733 of file SDL_blendline.c.

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

Referenced by SW_RenderDrawLines().

735 {
736  int i;
737  int x1, y1;
738  int x2, y2;
739  SDL_bool draw_end;
741 
742  if (!dst) {
743  return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
744  }
745 
746  func = SDL_CalculateBlendLineFunc(dst->format);
747  if (!func) {
748  return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
749  }
750 
751  for (i = 1; i < count; ++i) {
752  x1 = points[i-1].x;
753  y1 = points[i-1].y;
754  x2 = points[i].x;
755  y2 = points[i].y;
756 
757  /* Perform clipping */
758  /* FIXME: We don't actually want to clip, as it may change line slope */
759  if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
760  continue;
761  }
762 
763  /* Draw the end if it was clipped */
764  draw_end = (x2 != points[i].x || y2 != points[i].y);
765 
766  func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
767  }
768  if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
769  SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
770  blendMode, r, g, b, a);
771  }
772  return 0;
773 }
void(* BlendLineFunc)(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_bool draw_end)
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
GLuint GLfloat GLfloat GLfloat x1
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
GLfixed GLfixed GLfixed y2
GLfixed GLfixed x2
GLfixed y1
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
int x
Definition: SDL_rect.h:50
int y
Definition: SDL_rect.h:51
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_Rect clip_rect
Definition: SDL_surface.h:85
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
SDL_bool
Definition: SDL_stdinc.h:139
SDL_PixelFormat * format
Definition: SDL_surface.h:72
#define SDL_SetError
GLenum func
int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
#define SDL_IntersectRectAndLine
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g
GLboolean GLboolean GLboolean b