This repository was archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcdlv.h
126 lines (103 loc) · 3 KB
/
cdlv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef CDLV_H
#define CDLV_H
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#ifdef CDLV_FFMPEG
#include <libavcodec/avcodec.h>
#include <libavutil/imgutils.h>
#include <libavformat/avformat.h>
#endif
#include "scl/scl.h"
#define cdlv_max_string_size UINT16_MAX
#define cdlv_small_string UINT8_MAX
#define cdlv_max_choice_count UINT8_MAX
typedef sdic cdlv_dict;
typedef struct cdlv_color {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} cdlv_color;
typedef struct cdlv_vec2 {
uint64_t x;
uint64_t y;
} cdlv_vec2;
typedef struct cdlv_yuv_plane {
uint8_t* y;
uint8_t* u;
uint8_t* v;
} cdlv_yuv_plane;
typedef struct cdlv_yuv_pitch {
int y;
int u;
int v;
} cdlv_yuv_pitch;
typedef enum {
cdlv_ok,
cdlv_memory_error,
cdlv_file_error,
cdlv_read_error,
cdlv_video_error,
cdlv_parse_error,
cdlv_fatal_error,
cdlv_callback_error,
} cdlv_error;
typedef void (*cdlv_log_callback)(char* buf);
typedef void (*cdlv_error_callback)(cdlv_error error, void* user_data);
typedef struct cdlv_log_config {
cdlv_log_callback callback;
char* buffer;
size_t buffer_size;
} cdlv_log_config;
typedef struct cdlv_error_config {
cdlv_error_callback callback;
void* user_data;
} cdlv_error_config;
typedef void* (*cdlv_image_load_cb)(const char* path, void* user_data);
typedef void (*cdlv_image_render_cb)(void* image, void* user_data);
typedef void (*cdlv_image_free_cb)(void* image);
typedef struct cdlv_image_config {
cdlv_image_load_cb load_callback;
cdlv_image_render_cb render_callback;
cdlv_image_free_cb free_callback;
void* user_data;
} cdlv_image_config;
typedef void* (*cdlv_video_load_cb)(const uint64_t width, const uint64_t height, void* user_data);
typedef void (*cdlv_video_update_cb)(cdlv_yuv_plane plane, cdlv_yuv_pitch pitch, void* texture, void* user_data);
typedef void (*cdlv_video_free_cb)(void* texture);
typedef struct cdlv_video_config {
cdlv_video_load_cb load_callback;
cdlv_video_free_cb free_callback;
cdlv_video_update_cb update_callback;
void* user_data;
bool change_frame_bool;
} cdlv_video_config;
typedef int (*cdlv_user_update_cb)(void* user_data);
typedef void (*cdlv_line_cb)(const char* line, void* user_data);
typedef struct cdlv_user_config {
cdlv_user_update_cb update_callback;
cdlv_line_cb line_callback;
void* user_data;
} cdlv_user_config;
typedef struct cdlv {
cdlv_log_config log_config;
cdlv_error_config error_config;
cdlv_image_config image_config;
cdlv_video_config video_config;
cdlv_user_config user_config;
bool end;
cdlv_dict* scenes;
uint16_t scene_count;
uint16_t current_line;
uint16_t current_scene_index;
void* current_scene;
void* current_bg;
char* resources_path;
cdlv_dict* resources;
} cdlv;
cdlv_error cdlv_set_script(cdlv* base, const char* path);
cdlv_error cdlv_unset_script(cdlv* base);
cdlv_error cdlv_render(cdlv* base);
cdlv_error cdlv_user_update(cdlv* base);
#endif