1 | #ifndef RENDERER_H |
2 | #define RENDERER_H |
3 | |
4 | #include <SDL.h> |
5 | #include <stdint.h> |
6 | #include <stdbool.h> |
7 | |
8 | #ifdef __GNUC__ |
9 | #define UNUSED __attribute__((__unused__)) |
10 | #else |
11 | #define UNUSED |
12 | #endif |
13 | |
14 | |
15 | #define FONT_FALLBACK_MAX 10 |
16 | typedef struct RenFont RenFont; |
17 | typedef enum { FONT_HINTING_NONE, FONT_HINTING_SLIGHT, FONT_HINTING_FULL } ERenFontHinting; |
18 | typedef enum { FONT_ANTIALIASING_NONE, FONT_ANTIALIASING_GRAYSCALE, FONT_ANTIALIASING_SUBPIXEL } ERenFontAntialiasing; |
19 | typedef enum { FONT_STYLE_BOLD = 1, FONT_STYLE_ITALIC = 2, FONT_STYLE_UNDERLINE = 4, FONT_STYLE_SMOOTH = 8, FONT_STYLE_STRIKETHROUGH = 16 } ERenFontStyle; |
20 | typedef struct { uint8_t b, g, r, a; } RenColor; |
21 | typedef struct { int x, y, width, height; } RenRect; |
22 | typedef struct { SDL_Surface *surface; int scale; } RenSurface; |
23 | |
24 | struct RenWindow; |
25 | typedef struct RenWindow RenWindow; |
26 | extern RenWindow window_renderer; |
27 | |
28 | RenFont* ren_font_load(RenWindow *window_renderer, const char *filename, float size, ERenFontAntialiasing antialiasing, ERenFontHinting hinting, unsigned char style); |
29 | RenFont* ren_font_copy(RenWindow *window_renderer, RenFont* font, float size, ERenFontAntialiasing antialiasing, ERenFontHinting hinting, int style); |
30 | const char* ren_font_get_path(RenFont *font); |
31 | void ren_font_free(RenFont *font); |
32 | int ren_font_group_get_tab_size(RenFont **font); |
33 | int ren_font_group_get_height(RenFont **font); |
34 | float ren_font_group_get_size(RenFont **font); |
35 | void ren_font_group_set_size(RenWindow *window_renderer, RenFont **font, float size); |
36 | void ren_font_group_set_tab_size(RenFont **font, int n); |
37 | double ren_font_group_get_width(RenWindow *window_renderer, RenFont **font, const char *text, size_t len); |
38 | double ren_draw_text(RenSurface *rs, RenFont **font, const char *text, size_t len, float x, int y, RenColor color); |
39 | |
40 | void ren_draw_rect(RenSurface *rs, RenRect rect, RenColor color); |
41 | |
42 | void ren_init(SDL_Window *win); |
43 | void ren_resize_window(RenWindow *window_renderer); |
44 | void ren_update_rects(RenWindow *window_renderer, RenRect *rects, int count); |
45 | void ren_set_clip_rect(RenWindow *window_renderer, RenRect rect); |
46 | void ren_get_size(RenWindow *window_renderer, int *x, int *y); /* Reports the size in points. */ |
47 | void ren_free_window_resources(RenWindow *window_renderer); |
48 | |
49 | |
50 | #endif |
51 | |