-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlayer.h
145 lines (103 loc) · 2.51 KB
/
layer.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef _WF_LAYER_H
#define _WF_LAYER_H
#include "config.h"
#include "dbg.h"
#include "gl_env.h"
#define uarg(s, key, value) glUniform1f( glGetUniformLocation(s->progid, key), value )
#define uarg4(s, key, num, value) glUniform4fv( glGetUniformLocation(s->progid, key), num, value)
#define uarg3(s, key, num, value) glUniform3fv( glGetUniformLocation(s->progid, key), num, value)
#define uarg2fv(s, key, num, value) glUniform2fv( glGetUniformLocation(s->progid, key), num, value )
enum layerstate {UNUSED, UNINITIALIZED, LOADING, INITIALIZED, SHOWN};
enum blendmode {
NSA, // 1 - src alpha
NSC, // 1 - src color
SC, // src color
SA, // src alpha
SS, // src saturate
NDA, // 1 - dst alpha
NDC, // 1 - dst color
DC, // dst color
DA, // dst alpha
CA, // const alpha
CC // const color
};
enum blendeq {
FA, // FUNC_ADD
FS, // FUNC_SUBTRACT
FRS, // FUNC_REVERSE_SUBTRACT
FMIN, // MIN
FMAX // MAX
};
typedef struct {
double when;
float cps;
float dur;
char *words;
float r;
float g;
float b;
float a;
float x;
float y;
float z;
float w;
float rot_x;
float rot_y;
float rot_z;
float origin_x;
float origin_y;
float origin_z;
float width;
float height;
float speed;
int srcblend;
int dstblend;
int blendeq;
int level;
} t_showargs;
struct layer_t;
typedef void (*f_layer_apply)(struct layer_t *l);
typedef void (*f_layer_init)(struct layer_t *l);
typedef int (*f_layer_read_cache)(struct layer_t *cached, struct layer_t *uncached);
typedef struct layer_t
{
enum layerstate state;
int type_flag;
double when;
float cps;
float duration;
float color[4];
float pos[4];
float rot[3]; /* quaternions?! */
float origin[3];
float width;
float height;
float speed;
int is_image;
enum blendmode srcblend;
enum blendmode dstblend;
enum blendeq blendeq;
int level;
char *filename;
char *filecontent;
/* void *layer_data; */
/* f_layer_apply f_apply; */
/* f_layer_init f_init; */
/* f_layer_read_cache f_read_cache; */
unsigned int progid;
unsigned int shaderid;
unsigned int textid;
GLuint vao;
GLuint vbo;
struct layer_t *next, *prev;
} layer;
#include "queue.h"
struct layer_t* layer_new();
void map_show_args(layer *l);
void layer_init(layer *l, t_showargs *args);
void layer_add(t_showargs args, int is_image, int textid);
void layer_apply(layer *l, int even);
void layer_copy_program(layer *cached, layer *uncached);
GLint _shader_load(const char* filename, GLenum type);
GLuint get_vertex_shader();
#endif