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