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