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-04-24 10:21:34 +02:00
|
|
|
#include "fontdesc.h"
|
2019-12-28 12:16:32 +01:00
|
|
|
|
|
|
|
typedef struct RenImage RenImage;
|
|
|
|
|
2020-12-04 16:15:54 +01:00
|
|
|
enum {
|
|
|
|
RenFontAntialiasingMask = 1,
|
|
|
|
RenFontGrayscale = 1,
|
|
|
|
RenFontSubpixel = 0,
|
|
|
|
|
|
|
|
RenFontHintingMask = 3 << 1,
|
|
|
|
RenFontHintingSlight = 0 << 1,
|
|
|
|
RenFontHintingNone = 1 << 1,
|
|
|
|
RenFontHintingFull = 2 << 1,
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2021-03-31 17:33:35 +02:00
|
|
|
struct CPReplace {
|
|
|
|
unsigned codepoint_src;
|
|
|
|
unsigned codepoint_dst;
|
|
|
|
};
|
|
|
|
typedef struct CPReplace CPReplace;
|
|
|
|
|
|
|
|
|
|
|
|
struct CPReplaceTable {
|
|
|
|
int size;
|
|
|
|
CPReplace *replacements;
|
|
|
|
};
|
|
|
|
typedef struct CPReplaceTable CPReplaceTable;
|
|
|
|
|
2019-12-28 12:16:32 +01:00
|
|
|
|
|
|
|
void ren_init(SDL_Window *win);
|
2021-04-29 14:15:24 +02:00
|
|
|
void ren_resize_window();
|
2019-12-28 12:16:32 +01:00
|
|
|
void ren_update_rects(RenRect *rects, int count);
|
|
|
|
void ren_set_clip_rect(RenRect rect);
|
2021-04-24 10:21:34 +02:00
|
|
|
void ren_get_size(int *x, int *y); /* Reports the size in points. */
|
2021-04-23 14:54:25 +02:00
|
|
|
void ren_free_window_resources();
|
2019-12-28 12:16:32 +01:00
|
|
|
|
|
|
|
RenImage* ren_new_image(int width, int height);
|
|
|
|
void ren_free_image(RenImage *image);
|
|
|
|
|
2020-12-04 16:15:54 +01:00
|
|
|
RenFont* ren_load_font(const char *filename, float size, unsigned int renderer_flags);
|
2021-04-24 10:21:34 +02:00
|
|
|
int ren_verify_font(const char *filename);
|
2019-12-28 12:16:32 +01:00
|
|
|
void ren_free_font(RenFont *font);
|
2021-03-18 13:54:33 +01:00
|
|
|
void ren_set_font_tab_size(RenFont *font, int n);
|
|
|
|
int ren_get_font_tab_size(RenFont *font);
|
2021-04-24 10:21:34 +02:00
|
|
|
|
|
|
|
int ren_get_font_width(FontDesc *font_desc, const char *text, int *subpixel_scale);
|
|
|
|
int ren_get_font_height(FontDesc *font_desc);
|
|
|
|
int ren_get_font_subpixel_scale(FontDesc *font_desc);
|
2021-03-06 16:18:24 +01:00
|
|
|
int ren_font_subpixel_round(int width, int subpixel_scale, int orientation);
|
2019-12-28 12:16:32 +01:00
|
|
|
|
|
|
|
void ren_draw_rect(RenRect rect, RenColor color);
|
2021-04-24 10:21:34 +02:00
|
|
|
void ren_draw_text(FontDesc *font_desc, const char *text, int x, int y, RenColor color, CPReplaceTable *replacements, RenColor replace_color);
|
|
|
|
void ren_draw_text_subpixel(FontDesc *font_desc, const char *text, int x_subpixel, int y, RenColor color, CPReplaceTable *replacements, RenColor replace_color);
|
2021-03-31 17:33:35 +02:00
|
|
|
|
|
|
|
void ren_cp_replace_init(CPReplaceTable *rep_table);
|
|
|
|
void ren_cp_replace_free(CPReplaceTable *rep_table);
|
|
|
|
void ren_cp_replace_add(CPReplaceTable *rep_table, const char *src, const char *dst);
|
|
|
|
void ren_cp_replace_clear(CPReplaceTable *rep_table);
|
2019-12-28 12:16:32 +01:00
|
|
|
|
|
|
|
#endif
|