Debian Codegraph @

particles.c

raw symbols SCIP
1 #cxx . . $ `<file>/particles.c`/include <assert.h>
2 #include <lua.h>
3 #include <lualib.h>
4 #include <lauxlib.h>
5
6 #ifdef __APPLE__
7 #include "OpenGL/gl.h"
8 #include "OpenGL/glu.h"
9 #else
10 #include "GL/gl.h"
11 #include "GL/glu.h"
12 #endif
13
14 #define emitter_udatacxx . . $ `particles.c:14:9`! "particles.emitter"
15 #define PARTICLE_COUNTcxx . . $ `particles.c:15:9`! 2000
16
17 typedef structcxx . . $ $anonymous_type_725a1709d3476c9f_0# {
18 int lifecxx . . $ $anonymous_type_725a1709d3476c9f_0#life.;
19 float xcxx . . $ $anonymous_type_725a1709d3476c9f_0#x.;
20 float ycxx . . $ $anonymous_type_725a1709d3476c9f_0#y.;
21 float xvelcxx . . $ $anonymous_type_725a1709d3476c9f_0#xvel.;
22 float yvelcxx . . $ $anonymous_type_725a1709d3476c9f_0#yvel.;
23 float scalecxx . . $ $anonymous_type_725a1709d3476c9f_0#scale.;
24 } particle_tcxx . . $ particle_t#;
25
26 typedef structcxx . . $ $anonymous_type_725a1709d3476c9f_1# {
27 int texturecxx . . $ $anonymous_type_725a1709d3476c9f_1#texture.;
28 float widthcxx . . $ $anonymous_type_725a1709d3476c9f_1#width.;
29 float heightcxx . . $ $anonymous_type_725a1709d3476c9f_1#height.;
30 int lifecxx . . $ $anonymous_type_725a1709d3476c9f_1#life.;
31 float dampingcxx . . $ $anonymous_type_725a1709d3476c9f_1#damping.;
32 float delta_scalecxx . . $ $anonymous_type_725a1709d3476c9f_1#delta_scale.;
33 int nextcxx . . $ $anonymous_type_725a1709d3476c9f_1#next.;
34 particle_tcxx . . $ particle_t# particlescxx . . $ $anonymous_type_725a1709d3476c9f_1#particles.[PARTICLE_COUNTcxx . . $ `particles.c:15:9`!];
35 } emitter_tcxx . . $ emitter_t#;
36
37 static inline void draw_particlecxx . . $ draw_particle(f9b94c84c129e464).(emitter_tcxx . . $ emitter_t# *emitter, particle_tcxx . . $ particle_t# *particle)
38 {
39 if(particle->lifecxx . . $ $anonymous_type_725a1709d3476c9f_0#life.)
40 {
41 float dx = emitter->widthcxx . . $ $anonymous_type_725a1709d3476c9f_1#width./2 * particle->scalecxx . . $ $anonymous_type_725a1709d3476c9f_0#scale.;
42 float dy = emitter->heightcxx . . $ $anonymous_type_725a1709d3476c9f_1#height./2 * particle->scalecxx . . $ $anonymous_type_725a1709d3476c9f_0#scale.;
43 glColor4fcxx . . $ glColor4f(7e9a355db6148521).(1, 1, 1, (float)particle->lifecxx . . $ $anonymous_type_725a1709d3476c9f_0#life. / emitter->lifecxx . . $ $anonymous_type_725a1709d3476c9f_1#life.);
44 glTexCoord2dcxx . . $ glTexCoord2d(bc12c9ec15586e6a).(0, 1);
45 glVertex2fcxx . . $ glVertex2f(5102ef758adc0ae7).(particle->xcxx . . $ $anonymous_type_725a1709d3476c9f_0#x. - dx, particle->ycxx . . $ $anonymous_type_725a1709d3476c9f_0#y. - dy);
46 glTexCoord2dcxx . . $ glTexCoord2d(bc12c9ec15586e6a).(1, 1);
47 glVertex2fcxx . . $ glVertex2f(5102ef758adc0ae7).(particle->xcxx . . $ $anonymous_type_725a1709d3476c9f_0#x. + dx, particle->ycxx . . $ $anonymous_type_725a1709d3476c9f_0#y. - dy);
48 glTexCoord2dcxx . . $ glTexCoord2d(bc12c9ec15586e6a).(1, 0);
49 glVertex2fcxx . . $ glVertex2f(5102ef758adc0ae7).(particle->xcxx . . $ $anonymous_type_725a1709d3476c9f_0#x. + dx, particle->ycxx . . $ $anonymous_type_725a1709d3476c9f_0#y. + dy);
50 glTexCoord2dcxx . . $ glTexCoord2d(bc12c9ec15586e6a).(0, 0);
51 glVertex2fcxx . . $ glVertex2f(5102ef758adc0ae7).(particle->xcxx . . $ $anonymous_type_725a1709d3476c9f_0#x. - dx, particle->ycxx . . $ $anonymous_type_725a1709d3476c9f_0#y. + dy);
52 }
53 }
54
55 static int emitter__drawcxx . . $ emitter__draw(e4b172c3fcff213).(lua_Statecxx . . $ lua_State# *L)
56 {
57 emitter_tcxx . . $ emitter_t# *emitter = luaL_checkudatacxx . . $ luaL_checkudata(ded294d5354abc01).(L, 1, "particles.emitter");
58 int i;
59
60 glEnablecxx . . $ glEnable(cb2f890c2fdad230).(GL_TEXTURE_2Dcxx . . $ `<external>/11565930711847777359/gl.h:611:9`!);
61 glBindTexturecxx . . $ glBindTexture(b4d55b1286ff73e8).(GL_TEXTURE_2Dcxx . . $ `<external>/11565930711847777359/gl.h:611:9`!, emitter->texturecxx . . $ $anonymous_type_725a1709d3476c9f_1#texture.);
62 glBegincxx . . $ glBegin(cb2f890c2fdad230).(GL_QUADScxx . . $ `<external>/11565930711847777359/gl.h:163:9`!);
63 for(i = emitter->nextcxx . . $ $anonymous_type_725a1709d3476c9f_1#next.; i != PARTICLE_COUNTcxx . . $ `particles.c:15:9`!; i++)
64 draw_particlecxx . . $ draw_particle(f9b94c84c129e464).(emitter, &emitter->particlescxx . . $ $anonymous_type_725a1709d3476c9f_1#particles.[i]);
65 for(i = 0; i != emitter->nextcxx . . $ $anonymous_type_725a1709d3476c9f_1#next.; i++)
66 draw_particlecxx . . $ draw_particle(f9b94c84c129e464).(emitter, &emitter->particlescxx . . $ $anonymous_type_725a1709d3476c9f_1#particles.[i]);
67 glEndcxx . . $ glEnd(49f6e7a06ebc5aa8).();
68 glBindTexturecxx . . $ glBindTexture(b4d55b1286ff73e8).(GL_TEXTURE_2Dcxx . . $ `<external>/11565930711847777359/gl.h:611:9`!, 0);
69 glDisablecxx . . $ glDisable(cb2f890c2fdad230).(GL_TEXTURE_2Dcxx . . $ `<external>/11565930711847777359/gl.h:611:9`!);
70
71 glColor3fcxx . . $ glColor3f(bd1040fe176e0786).(1, 1, 1);
72
73 return 0;
74 }
75
76 static int emitter__updatecxx . . $ emitter__update(e4b172c3fcff213).(lua_Statecxx . . $ lua_State# *L)
77 {
78 emitter_tcxx . . $ emitter_t# *emitter = luaL_checkudatacxx . . $ luaL_checkudata(ded294d5354abc01).(L, 1, emitter_udatacxx . . $ `particles.c:14:9`!);
79
80 particle_tcxx . . $ particle_t# *particle;
81 for(particle = emitter->particlescxx . . $ $anonymous_type_725a1709d3476c9f_1#particles.;
82 particle != emitter->particlescxx . . $ $anonymous_type_725a1709d3476c9f_1#particles. + PARTICLE_COUNTcxx . . $ `particles.c:15:9`!;
83 particle++)
84 {
85 if(particle->lifecxx . . $ $anonymous_type_725a1709d3476c9f_0#life.)
86 {
87 particle->lifecxx . . $ $anonymous_type_725a1709d3476c9f_0#life.--;
88 particle->xcxx . . $ $anonymous_type_725a1709d3476c9f_0#x. += particle->xvelcxx . . $ $anonymous_type_725a1709d3476c9f_0#xvel.;
89 particle->ycxx . . $ $anonymous_type_725a1709d3476c9f_0#y. += particle->yvelcxx . . $ $anonymous_type_725a1709d3476c9f_0#yvel.;
90 particle->xvelcxx . . $ $anonymous_type_725a1709d3476c9f_0#xvel. *= emitter->dampingcxx . . $ $anonymous_type_725a1709d3476c9f_1#damping.;
91 particle->yvelcxx . . $ $anonymous_type_725a1709d3476c9f_0#yvel. *= emitter->dampingcxx . . $ $anonymous_type_725a1709d3476c9f_1#damping.;
92 particle->scalecxx . . $ $anonymous_type_725a1709d3476c9f_0#scale. += emitter->delta_scalecxx . . $ $anonymous_type_725a1709d3476c9f_1#delta_scale.;
93 }
94 }
95
96 return 0;
97 }
98
99 static int emitter__add_particlecxx . . $ emitter__add_particle(e4b172c3fcff213).(lua_Statecxx . . $ lua_State# *L)
100 {
101 emitter_tcxx . . $ emitter_t# *emitter = luaL_checkudatacxx . . $ luaL_checkudata(ded294d5354abc01).(L, 1, emitter_udatacxx . . $ `particles.c:14:9`!);
102 float x = (float)luaL_checknumbercxx . . $ luaL_checknumber(128e298513b4e6b3).(L, 2);
103 float y = (float)luaL_checknumbercxx . . $ luaL_checknumber(128e298513b4e6b3).(L, 3);
104 float xvel = (float)luaL_checknumbercxx . . $ luaL_checknumber(128e298513b4e6b3).(L, 4);
105 float yvel = (float)luaL_checknumbercxx . . $ luaL_checknumber(128e298513b4e6b3).(L, 5);
106
107 // grab a particle slot from the emitter
108 particle_tcxx . . $ particle_t# *particle = &emitter->particlescxx . . $ $anonymous_type_725a1709d3476c9f_1#particles.[emitter->nextcxx . . $ $anonymous_type_725a1709d3476c9f_1#next.];
109 emitter->nextcxx . . $ $anonymous_type_725a1709d3476c9f_1#next. = (emitter->nextcxx . . $ $anonymous_type_725a1709d3476c9f_1#next. + 1) % PARTICLE_COUNTcxx . . $ `particles.c:15:9`!;
110
111 // initialize it
112 particle->lifecxx . . $ $anonymous_type_725a1709d3476c9f_0#life. = emitter->lifecxx . . $ $anonymous_type_725a1709d3476c9f_1#life.;
113 particle->xcxx . . $ $anonymous_type_725a1709d3476c9f_0#x. = x;
114 particle->ycxx . . $ $anonymous_type_725a1709d3476c9f_0#y. = y;
115 particle->xvelcxx . . $ $anonymous_type_725a1709d3476c9f_0#xvel. = xvel;
116 particle->yvelcxx . . $ $anonymous_type_725a1709d3476c9f_0#yvel. = yvel;
117 particle->scalecxx . . $ $anonymous_type_725a1709d3476c9f_0#scale. = 1;
118
119 return 0;
120 }
121
122 static int particles__make_emittercxx . . $ particles__make_emitter(e4b172c3fcff213).(lua_Statecxx . . $ lua_State# *L)
123 {
124 float width = (float)luaL_checknumbercxx . . $ luaL_checknumber(128e298513b4e6b3).(L, 1);
125 float height = (float)luaL_checknumbercxx . . $ luaL_checknumber(128e298513b4e6b3).(L, 2);
126 int texture = luaL_checkintcxx . . $ `<external>/18095755238171912061/lauxlib.h:104:9`!(L, 3);
127 int life = luaL_checkintcxx . . $ `<external>/18095755238171912061/lauxlib.h:104:9`!(L, 4);
128 float damping = luaL_checknumbercxx . . $ luaL_checknumber(128e298513b4e6b3).(L, 5);
129 float delta_scale = luaL_checknumbercxx . . $ luaL_checknumber(128e298513b4e6b3).(L, 6);
130
131 emitter_tcxx . . $ emitter_t# *emitter = lua_newuserdatacxx . . $ lua_newuserdata(bb92b2d7de290).(L, sizeof(emitter_tcxx . . $ emitter_t#));
132 luaL_getmetatablecxx . . $ `<external>/18095755238171912061/lauxlib.h:117:9`!(L, emitter_udatacxx . . $ `particles.c:14:9`!);
133 lua_setmetatablecxx . . $ lua_setmetatable(95e3aa3a3b4bb934).(L, -2);
134
135 emitter->widthcxx . . $ $anonymous_type_725a1709d3476c9f_1#width. = width;
136 emitter->heightcxx . . $ $anonymous_type_725a1709d3476c9f_1#height. = height;
137 emitter->texturecxx . . $ $anonymous_type_725a1709d3476c9f_1#texture. = texture;
138 emitter->lifecxx . . $ $anonymous_type_725a1709d3476c9f_1#life. = life;
139 emitter->dampingcxx . . $ $anonymous_type_725a1709d3476c9f_1#damping. = damping;
140 emitter->delta_scalecxx . . $ $anonymous_type_725a1709d3476c9f_1#delta_scale. = delta_scale;
141
142 emitter->nextcxx . . $ $anonymous_type_725a1709d3476c9f_1#next. = 0;
143 int i;
144 for(i = 0; i < PARTICLE_COUNTcxx . . $ `particles.c:15:9`!; i++)
145 {
146 emitter->particlescxx . . $ $anonymous_type_725a1709d3476c9f_1#particles.[i].lifecxx . . $ $anonymous_type_725a1709d3476c9f_0#life. = 0;
147 }
148
149 return 1;
150 }
151
152 static const luaL_regcxx . . $ `<external>/18095755238171912061/lauxlib.h:170:9`! emitter_libcxx . . $ emitter_lib.[] =
153 {
154 {"draw", emitter__drawcxx . . $ emitter__draw(e4b172c3fcff213).},
155 {"update", emitter__updatecxx . . $ emitter__update(e4b172c3fcff213).},
156 {"add_particle", emitter__add_particlecxx . . $ emitter__add_particle(e4b172c3fcff213).},
157 {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!}
158 };
159
160 static const luaL_Regcxx . . $ luaL_Reg# particles_libcxx . . $ particles_lib.[] =
161 {
162 {"make_emitter", particles__make_emittercxx . . $ particles__make_emitter(e4b172c3fcff213).},
163 {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!}
164 };
165
166 int luaopen_particlescxx . . $ luaopen_particles(e4b172c3fcff213).(lua_Statecxx . . $ lua_State# *L)
167 {
168 luaL_newmetatablecxx . . $ luaL_newmetatable(ac61bb1a0c4e7605).(L, "particles.emitter");
169 lua_pushvaluecxx . . $ lua_pushvalue(9637dd485cf22a1).(L, -1);
170 lua_setfieldcxx . . $ lua_setfield(5a7f0bea59244d1d).(L, -2, "__index");
171 luaL_registercxx . . $ luaL_register(78d27bf8f6419b9e).(L, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, emitter_libcxx . . $ emitter_lib.);
172
173 lua_newtablecxx . . $ `<external>/15848857005865937740/lua.h:256:9`!(L);
174 luaL_registercxx . . $ luaL_register(78d27bf8f6419b9e).(L, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, particles_libcxx . . $ particles_lib.);
175 return 1;
176 }
177