Project

General

Profile

Statistics
| Revision:

root / proj / libs / graph / include / graph.h @ 308

History | View | Annotate | Download (3.13 KB)

1 168 up20180642
#ifndef GRAPH_H_INCLUDED
2
#define GRAPH_H_INCLUDED
3
4 261 up20180642
// Graphics modes
5
#define INDEXED_1024_768        0x105
6
#define DIRECT_640_480_888      0x110
7
#define DIRECT_800_600_888      0x115
8
#define DIRECT_1024_768_888     0x118
9
#define DIRECT_1280_1024_565    0x11A
10
#define DIRECT_1280_1024_888    0x11B
11
#define LINEAR_FRAME_BUFFER_MD  BIT(14)
12
13 253 up20180642
// Colors in RBG (8 bit)
14 307 up20180642
#define GRAPH_BLACK             0x000000
15
#define GRAPH_WHITE             0xFFFFFF
16
#define GRAPH_TRANSPARENT       0x00
17
#define GRAPH_RED               0xFF0000
18 253 up20180642
19
// Alpha
20
#define ALPHA_THRESHOLD     0x7F
21
22 174 up20180642
/// MACROS
23 183 up20180642
#define GET_ALP(n)          (0xFF & ((n) >> 24))
24 168 up20180642
#define GET_RED(n)          (0xFF & ((n) >> 16))
25
#define GET_GRE(n)          (0xFF & ((n) >>  8))
26
#define GET_BLU(n)          (0xFF & (n      ))
27 183 up20180642
#define GET_COLOR(n)        (0xFFFFFF & (n))
28
#define SET_ALP(n)          (((n)&0xFF) << 24)
29 168 up20180642
#define SET_RED(n)          (((n)&0xFF) << 16)
30
#define SET_GRE(n)          (((n)&0xFF) <<  8)
31
#define SET_BLU(n)          (((n)&0xFF)      )
32 174 up20180642
#define SET_RGB(r,g,b)      (SET_RED(r) | SET_GRE(g) | SET_BLU(b))
33 168 up20180642
34 174 up20180642
/// PUBLIC GET
35
uint16_t   (graph_get_XRes)         (void);
36
uint16_t   (graph_get_YRes)         (void);
37 208 up20180642
uint16_t   (graph_get_bytes_pixel)  (void);
38 168 up20180642
39 174 up20180642
/// INIT
40
int (graph_init)(uint16_t mode);
41 168 up20180642
42 174 up20180642
/// CLEANUP
43 168 up20180642
int (graph_cleanup)(void);
44
45 174 up20180642
/// PIXEL DRAWING
46 183 up20180642
int (graph_set_pixel)             (uint16_t x, uint16_t y, uint32_t color);
47 208 up20180642
void (graph_set_pixel_pos)         (unsigned pos          , uint32_t color);
48 168 up20180642
49 174 up20180642
/// SCREEN
50
int (graph_clear_screen)(void);
51 168 up20180642
52 174 up20180642
/// DRAW
53
int (graph_draw)(void);
54 168 up20180642
55 285 up20180642
/// SPRITE ================================
56
struct basic_sprite;
57
typedef struct basic_sprite basic_sprite_t;
58
59
basic_sprite_t* (basic_sprite_ctor)(const char **xpm, int16_t u0, int16_t v0);
60
void            (basic_sprite_dtor)(basic_sprite_t *p);
61
const uint8_t* (basic_sprite_get_map)(const basic_sprite_t *p);
62
uint16_t       (basic_sprite_get_w)  (const basic_sprite_t *p);
63
uint16_t       (basic_sprite_get_h)  (const basic_sprite_t *p);
64
int16_t        (basic_sprite_get_u0) (const basic_sprite_t *p);
65
int16_t        (basic_sprite_get_v0) (const basic_sprite_t *p);
66
67
struct sprite;
68
typedef struct sprite sprite_t;
69
70
sprite_t* (sprite_ctor)(const basic_sprite_t *bsp);
71
/*
72
 * /!\ WARNING: Entity destructor does not destruct the basic_sprite passed as
73
 * constructor arguments, since it is assumed the same basic_sprite may be used to
74
 * draw several sprites. It is thus YOUR responsibility to delete basic_sprite's.
75
 * @param   p   Pointer to sprite_t to be destructed
76
 */
77
void      (sprite_dtor)(sprite_t *p);
78
79
void (sprite_set_pos)   (sprite_t *p, int16_t x, int16_t y);
80
void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0);
81
void (sprite_set_angle) (sprite_t *p, double angle);
82
void (sprite_set_scale) (sprite_t *p, double scale);
83
84
int16_t  (sprite_get_x)(const sprite_t *p);
85
int16_t  (sprite_get_y)(const sprite_t *p);
86
double   (sprite_get_angle)(const sprite_t *p);
87
uint16_t (sprite_get_w)(const sprite_t *p);
88
uint16_t (sprite_get_h)(const sprite_t *p);
89
90
void (sprite_draw)(const sprite_t *p);
91
92 168 up20180642
#endif /* end of include guard: GRAPH_H_INCLUDED */