Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.99 KB)

1
#ifndef GRAPH_H_INCLUDED
2
#define GRAPH_H_INCLUDED
3

    
4
/**
5
 * @defgroup    graph   graph
6
 * @ingroup libs
7
 * @brief Graph module.
8
 *
9
 * Provides functions, classes and methods for graphic drawing.
10
 *
11
 * @{
12
 */
13

    
14
// Graphics modes
15
/// @brief Indexed graphic mode, 1024x768 px
16
#define INDEXED_1024_768        0x105
17
/// @brief Direct graphic mode, 640x480 px, RGB = 888 bits
18
#define DIRECT_640_480_888      0x110
19
/// @brief Direct graphic mode, 800x600 px, RGB = 888 bits
20
#define DIRECT_800_600_888      0x115
21
/// @brief Direct graphic mode, 1024x768 px, RGB = 888 bits
22
#define DIRECT_1024_768_888     0x118
23
/// @brief Direct graphic mode, 1280x1024 px, RGB = 565 bits
24
#define DIRECT_1280_1024_565    0x11A
25
/// @brief Direct graphic mode, 1280x1024 px, RGB = 888 bits
26
#define DIRECT_1280_1024_888    0x11B
27

    
28
// Colors in RBG (8 bit)
29
/// @brief Black color
30
#define GRAPH_BLACK             0x000000
31
/// @brief White color
32
#define GRAPH_WHITE             0xFFFFFF
33
/// @brief Transparent
34
#define GRAPH_TRANSPARENT       0x00
35
/// @brief Red color
36
#define GRAPH_RED               0xFF0000
37

    
38
/// @brief Alpha threshold, from which it is either considered transparent or opaque
39
#define ALPHA_THRESHOLD     0x7F
40

    
41
/**
42
 * @brief Initialize graphics.
43
 * @param   mode    Graphics mode to use
44
 * @return  SUCCESS if operation was successful, other value otherwise
45
 */
46
int (graph_init)(uint16_t mode);
47

    
48
/**
49
 * @brief Cleanup graphics.
50
 * @return  SUCCESS if operation was successful, other value otherwise
51
 */
52
int (graph_cleanup)(void);
53

    
54
/**
55
 * @brief Get screen X-resolution.
56
 * @return Screen X-resolution
57
 */
58
uint16_t   (graph_get_XRes)         (void);
59
/**
60
 * @brief Get screen Y-resolution.
61
 * @return Screen Y-resolution
62
 */
63
uint16_t   (graph_get_YRes)         (void);
64
/**
65
 * @brief Get number of bytes per pixel.
66
 *
67
 * That is, the number of bytes needed to encode the color of a pixel.
68
 * @return Number of bytes per pixel
69
 */
70
uint16_t   (graph_get_bytes_pixel)  (void);
71

    
72
/**
73
 * @brief Draw pixel with color.
74
 * @param   x       X-position of pixel to draw
75
 * @param   y       Y-position of pixel to draw
76
 * @param   color   Color that will be used to draw the pixel
77
 * @return  SUCCESS if operation was successful, other value otherwise
78
 */
79
void (graph_set_pixel)             (uint16_t x, uint16_t y, uint32_t color);
80
/**
81
 * @brief Draw pixel with color using position.
82
 *
83
 * Position is calculated from y*WIDTH+x.
84
 * @param   pos     Position
85
 * @param   color   Color that will be used to draw the pixel
86
 */
87
void (graph_set_pixel_pos)         (unsigned pos          , uint32_t color);
88

    
89
/**
90
 * @brief Clear screen, painting it black.
91
 * @return  SUCCESS if operation was successful, other value otherwise
92
 */
93
int (graph_clear_screen)(void);
94

    
95
/**
96
 * @brief Draw everything on the buffer to the screen.
97
 * @return  SUCCESS if operation was successful, other value otherwise
98
 */
99
int (graph_draw)(void);
100

    
101
/**
102
 * @}
103
 */
104

    
105
#endif /* end of include guard: GRAPH_H_INCLUDED */