2019-12-28 12:16:32 +01:00
|
|
|
#ifndef RENDERER_H
|
|
|
|
#define RENDERER_H
|
|
|
|
|
2020-06-29 15:24:08 +02:00
|
|
|
#include <SDL.h>
|
2019-12-28 12:16:32 +01:00
|
|
|
#include <stdint.h>
|
2021-09-11 04:22:30 +02:00
|
|
|
#include <stdbool.h>
|
2020-12-04 16:15:54 +01:00
|
|
|
|
2022-04-15 17:34:46 +02:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define UNUSED __attribute__((__unused__))
|
|
|
|
#else
|
|
|
|
#define UNUSED
|
|
|
|
#endif
|
|
|
|
|
2023-01-22 04:11:42 +01:00
|
|
|
|
2022-10-20 03:12:04 +02:00
|
|
|
#define FONT_FALLBACK_MAX 10
|
2021-09-11 04:22:30 +02:00
|
|
|
typedef struct RenFont RenFont;
|
|
|
|
typedef enum { FONT_HINTING_NONE, FONT_HINTING_SLIGHT, FONT_HINTING_FULL } ERenFontHinting;
|
2021-11-23 00:13:43 +01:00
|
|
|
typedef enum { FONT_ANTIALIASING_NONE, FONT_ANTIALIASING_GRAYSCALE, FONT_ANTIALIASING_SUBPIXEL } ERenFontAntialiasing;
|
2022-08-20 22:15:08 +02:00
|
|
|
typedef enum { FONT_STYLE_BOLD = 1, FONT_STYLE_ITALIC = 2, FONT_STYLE_UNDERLINE = 4, FONT_STYLE_SMOOTH = 8, FONT_STYLE_STRIKETHROUGH = 16 } ERenFontStyle;
|
2019-12-28 12:16:32 +01:00
|
|
|
typedef struct { uint8_t b, g, r, a; } RenColor;
|
|
|
|
typedef struct { int x, y, width, height; } RenRect;
|
2023-03-19 20:39:52 +01:00
|
|
|
typedef struct { SDL_Surface *surface; int scale; } RenSurface;
|
2019-12-28 12:16:32 +01:00
|
|
|
|
2023-01-22 04:11:42 +01:00
|
|
|
struct RenWindow;
|
|
|
|
typedef struct RenWindow RenWindow;
|
|
|
|
extern RenWindow window_renderer;
|
|
|
|
|
|
|
|
RenFont* ren_font_load(RenWindow *window_renderer, const char *filename, float size, ERenFontAntialiasing antialiasing, ERenFontHinting hinting, unsigned char style);
|
|
|
|
RenFont* ren_font_copy(RenWindow *window_renderer, RenFont* font, float size, ERenFontAntialiasing antialiasing, ERenFontHinting hinting, int style);
|
2022-06-22 19:19:52 +02:00
|
|
|
const char* ren_font_get_path(RenFont *font);
|
2021-09-11 04:22:30 +02:00
|
|
|
void ren_font_free(RenFont *font);
|
2021-10-13 05:24:52 +02:00
|
|
|
int ren_font_group_get_tab_size(RenFont **font);
|
|
|
|
int ren_font_group_get_height(RenFont **font);
|
|
|
|
float ren_font_group_get_size(RenFont **font);
|
2023-01-22 04:11:42 +01:00
|
|
|
void ren_font_group_set_size(RenWindow *window_renderer, RenFont **font, float size);
|
2021-10-13 05:24:52 +02:00
|
|
|
void ren_font_group_set_tab_size(RenFont **font, int n);
|
2023-11-29 21:44:48 +01:00
|
|
|
double ren_font_group_get_width(RenWindow *window_renderer, RenFont **font, const char *text, size_t len, int *x_offset);
|
2023-03-19 20:39:52 +01:00
|
|
|
double ren_draw_text(RenSurface *rs, RenFont **font, const char *text, size_t len, float x, int y, RenColor color);
|
2021-03-31 17:33:35 +02:00
|
|
|
|
2023-03-19 20:39:52 +01:00
|
|
|
void ren_draw_rect(RenSurface *rs, RenRect rect, RenColor color);
|
2019-12-28 12:16:32 +01:00
|
|
|
|
|
|
|
void ren_init(SDL_Window *win);
|
2023-01-22 04:11:42 +01:00
|
|
|
void ren_resize_window(RenWindow *window_renderer);
|
|
|
|
void ren_update_rects(RenWindow *window_renderer, RenRect *rects, int count);
|
|
|
|
void ren_set_clip_rect(RenWindow *window_renderer, RenRect rect);
|
|
|
|
void ren_get_size(RenWindow *window_renderer, int *x, int *y); /* Reports the size in points. */
|
|
|
|
void ren_free_window_resources(RenWindow *window_renderer);
|
2019-12-28 12:16:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|