-
Notifications
You must be signed in to change notification settings - Fork 0
/
DGLDRAW.H
executable file
·94 lines (76 loc) · 3.04 KB
/
DGLDRAW.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef LIBDGL_DGLDRAW_H
#define LIBDGL_DGLDRAW_H
#include "dglgfx.h"
#include "dglclip.h"
#include "dglutil.h"
#ifdef __cplusplus
extern "C" {
#endif
static void pset(SURFACE *surface, int x, int y, uint8 color);
static void pset_f(SURFACE *surface, int x, int y, uint8 color);
static uint8 pget(const SURFACE *surface, int x, int y);
static uint8 pget_f(const SURFACE *surface, int x, int y);
static void draw_hline(SURFACE *surface, int x1, int x2, int y, uint8 color);
void draw_hline_f(SURFACE *surface, int x1, int x2, int y, uint8 color);
static void draw_vline(SURFACE *surface, int x, int y1, int y2, uint8 color);
void draw_vline_f(SURFACE *surface, int x, int y1, int y2, uint8 color);
void draw_line(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
void draw_line_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
void draw_rect(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
void draw_rect_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
void draw_filled_rect(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
void draw_filled_rect_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
void draw_text(SURFACE *surface, int x, int y, uint8 color, const char *text);
void draw_text_f(SURFACE *surface, int x, int y, uint8 color, const char *text);
void draw_printf(SURFACE *surface, int x, int y, uint8 color, const char *format, ...);
void draw_printf_f(SURFACE *surface, int x, int y, uint8 color, const char *format, ...);
void lowlevel_rect_f(
uint8 color,
int width,
int y_inc,
int lines,
uint8 *p1,
uint8 *p2
);
void lowlevel_filled_rect_f(
uint8 color,
int y_inc,
int width,
int lines,
uint8 *dest
);
// --------------------------------------------------------------------------
static void pset(SURFACE *surface, int x, int y, uint8 color) {
if (is_point_in_bounds(&surface->clip_region, x, y))
pset_f(surface, x, y, color);
}
static void pset_f(SURFACE *surface, int x, int y, uint8 color) {
uint32 offset = surface_offset(surface, x, y);
surface->pixels[offset] = color;
}
static uint8 pget(const SURFACE *surface, int x, int y) {
if (is_point_in_bounds(&surface->clip_region, x, y))
return pget_f(surface, x, y);
else
return 0;
}
static uint8 pget_f(const SURFACE *surface, int x, int y) {
uint32 offset = surface_offset(surface, x, y);
return surface->pixels[offset];
}
static void draw_hline(SURFACE *surface, int x1, int x2, int y, uint8 color) {
if (x2 < x1)
SWAP(int, x1, x2);
if (clamp_to_region(&surface->clip_region, &x1, &y, &x2, &y))
draw_hline_f(surface, x1, x2, y, color);
}
static void draw_vline(SURFACE *surface, int x, int y1, int y2, uint8 color) {
if (y2 < y1)
SWAP(int, y1, y2);
if (clamp_to_region(&surface->clip_region, &x, &y1, &x, &y2))
draw_vline_f(surface, x, y1, y2, color);
}
#ifdef __cplusplus
}
#endif
#endif