particles.h
2.84 KB
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
/*
TE4 - T-Engine 4
Copyright (C) 2009 - 2018 Nicolas Casalini
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Nicolas Casalini "DarkGod"
darkgod@te4.org
*/
#ifndef _PARTICLES_H_
#define _PARTICLES_H_
#include "tgl.h"
#include "useshader.h"
typedef struct {
float size, sizev, sizea;
float ox, oy;
float x, y, xv, yv, xa, ya;
float dir, dirv, dira, vel, velv, vela;
float r, g, b, a, rv, gv, bv, av, ra, ga, ba, aa;
int life;
int trail;
} particle_type;
struct s_plist;
struct s_particles_type {
SDL_mutex *lock;
// Read only by main
GLuint texture;
shader_type *shader;
// W by main, R by thread
const char *name_def;
const char *args;
float zoom;
// R/W only by thread
particle_type *particles;
int nb;
int density;
bool no_stop;
// W only by thread, R only by main
int batch_nb;
GLfloat *vertices;
GLfloat *colors;
GLshort *texcoords;
bool alive;
bool i_want_to_die;
bool init;
bool recompile;
// R/W only by thread
int base;
int angle_min, anglev_min, anglea_min;
int angle_max, anglev_max, anglea_max;
int size_min, sizev_min, sizea_min;
int x_min, y_min, xv_min, yv_min, xa_min, ya_min;
int r_min, g_min, b_min, a_min, rv_min, gv_min, bv_min, av_min, ra_min, ga_min, ba_min, aa_min;
int size_max, sizev_max, sizea_max;
int x_max, y_max, xv_max, yv_max, xa_max, ya_max;
int r_max, g_max, b_max, a_max, rv_max, gv_max, bv_max, av_max, ra_max, ga_max, ba_max, aa_max;
int life_min, life_max;
int engine, blend_mode;
float rotate, rotate_v;
bool fboalter;
struct s_particles_type *sub;
struct s_plist *l;
};
typedef struct s_particles_type particles_type;
//To draw last linked list
struct s_particle_draw_last {
particles_type *ps;
float x;
float y;
float zoom;
struct s_particle_draw_last *next;
};
typedef struct s_particle_draw_last particle_draw_last;
// Particles thread-only structure
struct s_particle_thread;
struct s_plist {
particles_type *ps;
int generator_ref;
int updator_ref;
int emit_ref;
struct s_particle_thread *pt;
struct s_plist *next;
};
typedef struct s_plist plist;
struct s_particle_thread {
int id;
bool running;
lua_State *L;
SDL_Thread *thread;
SDL_mutex *lock;
SDL_sem *keyframes;
plist *list;
jmp_buf panicjump;
};
typedef struct s_particle_thread particle_thread;
#endif