forked from jarcode-foss/glava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglsl_ext.h
38 lines (31 loc) · 1.43 KB
/
glsl_ext.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
#define RHANDLER(name, args, ...) \
({ void _handler(const char* name, void** args) __VA_ARGS__ _handler; })
struct request_handler {
const char* name;
/*
handler format:
'i' - signed integer (void* -> int*)
'f' - float (void* -> float*)
's' - string (void* -> const char*)
'b' - bool (void* -> bool*)
example:
.fmt = "sii" // takes a string, and then two integers
.fmt = "ffb" // takes two floats, then a boolean
*/
const char* fmt;
void (*handler)(const char* name, void** args);
};
struct glsl_ext {
char* processed; /* OUT: null terminated processed source */
size_t p_len; /* OUT: length of processed buffer, excluding null char */
const char* source; /* IN: raw data passed via ext_process */
size_t source_len; /* IN: raw source len */
const char* cd; /* IN: current directory */
const char* cfd; /* IN: config directory, if NULL it is assumed to cd */
/* IN: NULL (where the last element's 'name' member is NULL) terminated
array of request handlers */
struct request_handler* handlers;
};
void ext_process(struct glsl_ext* ext, const char* f);
void ext_free (struct glsl_ext* ext);
bool ext_parse_color(const char* hex, size_t elem_sz, float** results);