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

Go to the source code of this file.

Functions

int SDL_DrawPoint (SDL_Surface *dst, int x, int y, Uint32 color)
 
int SDL_DrawPoints (SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color)
 

Function Documentation

◆ SDL_DrawPoint()

int SDL_DrawPoint ( SDL_Surface dst,
int  x,
int  y,
Uint32  color 
)

Definition at line 30 of file SDL_drawpoint.c.

References SDL_PixelFormat::BitsPerPixel, SDL_PixelFormat::BytesPerPixel, SDL_Surface::clip_rect, DRAW_FASTSETPIXELXY1, DRAW_FASTSETPIXELXY2, DRAW_FASTSETPIXELXY4, SDL_Surface::format, SDL_Rect::h, SDL_SetError, SDL_Unsupported, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_DrawLines().

31 {
32  if (!dst) {
33  return SDL_SetError("Passed NULL destination surface");
34  }
35 
36  /* This function doesn't work on surfaces < 8 bpp */
37  if (dst->format->BitsPerPixel < 8) {
38  return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
39  }
40 
41  /* Perform clipping */
42  if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
43  x >= (dst->clip_rect.x + dst->clip_rect.w) ||
44  y >= (dst->clip_rect.y + dst->clip_rect.h)) {
45  return 0;
46  }
47 
48  switch (dst->format->BytesPerPixel) {
49  case 1:
51  break;
52  case 2:
54  break;
55  case 3:
56  return SDL_Unsupported();
57  case 4:
59  break;
60  }
61  return 0;
62 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
#define DRAW_FASTSETPIXELXY1(x, y)
Definition: SDL_draw.h:42
#define DRAW_FASTSETPIXELXY4(x, y)
Definition: SDL_draw.h:44
Uint8 BitsPerPixel
Definition: SDL_pixels.h:319
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
int x
Definition: SDL_rect.h:66
int w
Definition: SDL_rect.h:67
SDL_Rect clip_rect
Definition: SDL_surface.h:85
#define DRAW_FASTSETPIXELXY2(x, y)
Definition: SDL_draw.h:43
SDL_PixelFormat * format
Definition: SDL_surface.h:72
#define SDL_SetError
int h
Definition: SDL_rect.h:67
int y
Definition: SDL_rect.h:66
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_DrawPoints()

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

Definition at line 65 of file SDL_drawpoint.c.

References SDL_PixelFormat::BitsPerPixel, SDL_PixelFormat::BytesPerPixel, SDL_Surface::clip_rect, DRAW_FASTSETPIXELXY1, DRAW_FASTSETPIXELXY2, DRAW_FASTSETPIXELXY4, SDL_Surface::format, SDL_Rect::h, i, SDL_SetError, SDL_Unsupported, SDL_Rect::w, SDL_Point::x, SDL_Rect::x, SDL_Point::y, and SDL_Rect::y.

Referenced by SW_RenderDrawPoints().

67 {
68  int minx, miny;
69  int maxx, maxy;
70  int i;
71  int x, y;
72 
73  if (!dst) {
74  return SDL_SetError("Passed NULL destination surface");
75  }
76 
77  /* This function doesn't work on surfaces < 8 bpp */
78  if (dst->format->BitsPerPixel < 8) {
79  return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
80  }
81 
82  minx = dst->clip_rect.x;
83  maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
84  miny = dst->clip_rect.y;
85  maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
86 
87  for (i = 0; i < count; ++i) {
88  x = points[i].x;
89  y = points[i].y;
90 
91  if (x < minx || x > maxx || y < miny || y > maxy) {
92  continue;
93  }
94 
95  switch (dst->format->BytesPerPixel) {
96  case 1:
98  break;
99  case 2:
100  DRAW_FASTSETPIXELXY2(x, y);
101  break;
102  case 3:
103  return SDL_Unsupported();
104  case 4:
105  DRAW_FASTSETPIXELXY4(x, y);
106  break;
107  }
108  }
109  return 0;
110 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
#define DRAW_FASTSETPIXELXY1(x, y)
Definition: SDL_draw.h:42
#define DRAW_FASTSETPIXELXY4(x, y)
Definition: SDL_draw.h:44
int x
Definition: SDL_rect.h:50
int y
Definition: SDL_rect.h:51
Uint8 BitsPerPixel
Definition: SDL_pixels.h:319
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
int x
Definition: SDL_rect.h:66
int w
Definition: SDL_rect.h:67
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
#define DRAW_FASTSETPIXELXY2(x, y)
Definition: SDL_draw.h:43
SDL_PixelFormat * format
Definition: SDL_surface.h:72
#define SDL_SetError
int h
Definition: SDL_rect.h:67
int y
Definition: SDL_rect.h:66
#define SDL_Unsupported()
Definition: SDL_error.h:53