Merge lp:~bitzesmichail/compiz/wizardGLES into lp:compiz/0.9.10
- wizardGLES
- Merge into 0.9.10
Proposed by
Michail Bitzes
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | MC Return | ||||
Approved revision: | 3754 | ||||
Merged at revision: | 3756 | ||||
Proposed branch: | lp:~bitzesmichail/compiz/wizardGLES | ||||
Merge into: | lp:compiz/0.9.10 | ||||
Diff against target: |
508 lines (+204/-165) 5 files modified
debian/compiz-plugins.install.armel (+1/-0) debian/compiz-plugins.install.armhf (+1/-0) plugins/CMakeLists.txt (+0/-1) plugins/wizard/include/wizard.h (+14/-9) plugins/wizard/src/wizard.cpp (+188/-155) |
||||
To merge this branch: | bzr merge lp:~bitzesmichail/compiz/wizardGLES | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
MC Return | Approve | ||
Review via email: mp+173358@code.launchpad.net |
Commit message
Plugin wizard ported to OpenGL|ES.
Use GLVertexBuffer.
Enable building for GLES. Enable architectures armel and armhf.
(LP: #1196003)
Description of the change
Just the OpenGL|ES port. Bug #1195996 not fixed in this branch.
To post a comment you must log in.
Revision history for this message
MC Return (mc-return) wrote : | # |
Revision history for this message
MC Return (mc-return) wrote : | # |
This is now tested and worx perfectly as expected. :)
+1
review:
Approve
Revision history for this message
MC Return (mc-return) wrote : | # |
Andyrock told me trunk is unblocked, so this can still make it to 0.9.10.0 it seems. :)
review:
Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) : | # |
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/compiz-plugins.install.armel' | |||
2 | --- debian/compiz-plugins.install.armel 2013-02-03 22:55:55 +0000 | |||
3 | +++ debian/compiz-plugins.install.armel 2013-07-07 15:20:32 +0000 | |||
4 | @@ -44,6 +44,7 @@ | |||
5 | 44 | debian/tmp/usr/*/compiz/*wallpaper.* | 44 | debian/tmp/usr/*/compiz/*wallpaper.* |
6 | 45 | debian/tmp/usr/*/compiz/*water.* | 45 | debian/tmp/usr/*/compiz/*water.* |
7 | 46 | debian/tmp/usr/*/compiz/*winrules.* | 46 | debian/tmp/usr/*/compiz/*winrules.* |
8 | 47 | debian/tmp/usr/*/compiz/*wizard.* | ||
9 | 47 | debian/tmp/usr/*/compiz/*wobbly.* | 48 | debian/tmp/usr/*/compiz/*wobbly.* |
10 | 48 | debian/tmp/usr/*/compiz/*workspacenames.* | 49 | debian/tmp/usr/*/compiz/*workspacenames.* |
11 | 49 | 50 | ||
12 | 50 | 51 | ||
13 | === modified file 'debian/compiz-plugins.install.armhf' | |||
14 | --- debian/compiz-plugins.install.armhf 2013-02-03 22:55:55 +0000 | |||
15 | +++ debian/compiz-plugins.install.armhf 2013-07-07 15:20:32 +0000 | |||
16 | @@ -44,6 +44,7 @@ | |||
17 | 44 | debian/tmp/usr/*/compiz/*wallpaper.* | 44 | debian/tmp/usr/*/compiz/*wallpaper.* |
18 | 45 | debian/tmp/usr/*/compiz/*water.* | 45 | debian/tmp/usr/*/compiz/*water.* |
19 | 46 | debian/tmp/usr/*/compiz/*winrules.* | 46 | debian/tmp/usr/*/compiz/*winrules.* |
20 | 47 | debian/tmp/usr/*/compiz/*wizard.* | ||
21 | 47 | debian/tmp/usr/*/compiz/*wobbly.* | 48 | debian/tmp/usr/*/compiz/*wobbly.* |
22 | 48 | debian/tmp/usr/*/compiz/*workspacenames.* | 49 | debian/tmp/usr/*/compiz/*workspacenames.* |
23 | 49 | 50 | ||
24 | 50 | 51 | ||
25 | === modified file 'plugins/CMakeLists.txt' | |||
26 | --- plugins/CMakeLists.txt 2013-03-08 18:42:22 +0000 | |||
27 | +++ plugins/CMakeLists.txt 2013-07-07 15:20:32 +0000 | |||
28 | @@ -32,7 +32,6 @@ | |||
29 | 32 | set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON) | 32 | set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON) |
30 | 33 | set (COMPIZ_DISABLE_PLUGIN_WIDGET ON) | 33 | set (COMPIZ_DISABLE_PLUGIN_WIDGET ON) |
31 | 34 | set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON) | 34 | set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON) |
32 | 35 | set (COMPIZ_DISABLE_PLUGIN_WIZARD ON) | ||
33 | 36 | 35 | ||
34 | 37 | endif (BUILD_GLES) | 36 | endif (BUILD_GLES) |
35 | 38 | 37 | ||
36 | 39 | 38 | ||
37 | === modified file 'plugins/wizard/include/wizard.h' | |||
38 | --- plugins/wizard/include/wizard.h 2010-09-14 01:57:47 +0000 | |||
39 | +++ plugins/wizard/include/wizard.h 2013-07-07 15:20:32 +0000 | |||
40 | @@ -32,6 +32,11 @@ | |||
41 | 32 | #include "wizard_options.h" | 32 | #include "wizard_options.h" |
42 | 33 | #include "wizard_tex.h" | 33 | #include "wizard_tex.h" |
43 | 34 | 34 | ||
44 | 35 | extern const unsigned short CACHESIZE_FACTOR; | ||
45 | 36 | extern const unsigned short COORD_COMPONENTS; | ||
46 | 37 | extern const unsigned short VERTEX_COMPONENTS; | ||
47 | 38 | extern const unsigned short COLOR_COMPONENTS; | ||
48 | 39 | |||
49 | 35 | static float | 40 | static float |
50 | 36 | rRange (float avg, float range) | 41 | rRange (float avg, float range) |
51 | 37 | { | 42 | { |
52 | @@ -147,14 +152,13 @@ | |||
53 | 147 | int ne; // Emitter count | 152 | int ne; // Emitter count |
54 | 148 | int ng; // GPoint count | 153 | int ng; // GPoint count |
55 | 149 | 154 | ||
64 | 150 | GLfloat *vertices_cache; | 155 | /* Cache used in drawParticles |
65 | 151 | int vertex_cache_count; | 156 | It's here to avoid multiple mem allocation |
66 | 152 | GLfloat *coords_cache; | 157 | during drawing */ |
67 | 153 | int coords_cache_count; | 158 | std::vector<GLfloat> vertices_cache; |
68 | 154 | GLfloat *colors_cache; | 159 | std::vector<GLfloat> coords_cache; |
69 | 155 | int color_cache_count; | 160 | std::vector<GLushort> colors_cache; |
70 | 156 | GLfloat *dcolors_cache; | 161 | std::vector<GLushort> dcolors_cache; |
63 | 157 | int dcolors_cache_count; | ||
71 | 158 | }; | 162 | }; |
72 | 159 | 163 | ||
73 | 160 | class WizardScreen : | 164 | class WizardScreen : |
74 | @@ -183,7 +187,8 @@ | |||
75 | 183 | 187 | ||
76 | 184 | void loadEmitters (ParticleSystem *ps); | 188 | void loadEmitters (ParticleSystem *ps); |
77 | 185 | 189 | ||
79 | 186 | void drawParticles (ParticleSystem * ps); | 190 | void drawParticles (ParticleSystem *ps, |
80 | 191 | const GLMatrix &transform); | ||
81 | 187 | 192 | ||
82 | 188 | void positionUpdate (const CompPoint &pos); | 193 | void positionUpdate (const CompPoint &pos); |
83 | 189 | 194 | ||
84 | 190 | 195 | ||
85 | === modified file 'plugins/wizard/src/wizard.cpp' | |||
86 | --- plugins/wizard/src/wizard.cpp 2013-05-09 13:43:07 +0000 | |||
87 | +++ plugins/wizard/src/wizard.cpp 2013-07-07 15:20:32 +0000 | |||
88 | @@ -29,6 +29,18 @@ | |||
89 | 29 | 29 | ||
90 | 30 | #include "wizard.h" | 30 | #include "wizard.h" |
91 | 31 | 31 | ||
92 | 32 | /* 3 vertices per triangle, 2 triangles per particle */ | ||
93 | 33 | const unsigned short CACHESIZE_FACTOR = 3 * 2; | ||
94 | 34 | |||
95 | 35 | /* 2 coordinates, x and y */ | ||
96 | 36 | const unsigned short COORD_COMPONENTS = CACHESIZE_FACTOR * 2; | ||
97 | 37 | |||
98 | 38 | /* each vertex is stored as 3 GLfloats */ | ||
99 | 39 | const unsigned short VERTEX_COMPONENTS = CACHESIZE_FACTOR * 3; | ||
100 | 40 | |||
101 | 41 | /* 4 colors, RGBA */ | ||
102 | 42 | const unsigned short COLOR_COMPONENTS = CACHESIZE_FACTOR * 4; | ||
103 | 43 | |||
104 | 32 | static void | 44 | static void |
105 | 33 | initParticles (int hardLimit, int softLimit, ParticleSystem * ps) | 45 | initParticles (int hardLimit, int softLimit, ParticleSystem * ps) |
106 | 34 | { | 46 | { |
107 | @@ -42,14 +54,10 @@ | |||
108 | 42 | ps->lastCount = 0; | 54 | ps->lastCount = 0; |
109 | 43 | 55 | ||
110 | 44 | // Initialize cache | 56 | // Initialize cache |
119 | 45 | ps->vertices_cache = NULL; | 57 | ps->vertices_cache.clear (); |
120 | 46 | ps->colors_cache = NULL; | 58 | ps->coords_cache.clear (); |
121 | 47 | ps->coords_cache = NULL; | 59 | ps->colors_cache.clear (); |
122 | 48 | ps->dcolors_cache = NULL; | 60 | ps->dcolors_cache.clear (); |
115 | 49 | ps->vertex_cache_count = 0; | ||
116 | 50 | ps->color_cache_count = 0; | ||
117 | 51 | ps->coords_cache_count = 0; | ||
118 | 52 | ps->dcolors_cache_count = 0; | ||
123 | 53 | 61 | ||
124 | 54 | Particle *part = ps->particles; | 62 | Particle *part = ps->particles; |
125 | 55 | int i; | 63 | int i; |
126 | @@ -277,77 +285,41 @@ | |||
127 | 277 | } | 285 | } |
128 | 278 | 286 | ||
129 | 279 | void | 287 | void |
131 | 280 | WizardScreen::drawParticles (ParticleSystem * ps) | 288 | WizardScreen::drawParticles (ParticleSystem *ps, |
132 | 289 | const GLMatrix &transform) | ||
133 | 281 | { | 290 | { |
135 | 282 | glPushMatrix (); | 291 | int i, j, k, l; |
136 | 292 | |||
137 | 293 | /* Check that the cache is big enough */ | ||
138 | 294 | if (ps->vertices_cache.size () < (unsigned int)ps->hardLimit * VERTEX_COMPONENTS) | ||
139 | 295 | ps->vertices_cache.resize (ps->hardLimit * VERTEX_COMPONENTS); | ||
140 | 296 | |||
141 | 297 | if (ps->coords_cache.size () < (unsigned int)ps->hardLimit * COORD_COMPONENTS) | ||
142 | 298 | ps->coords_cache.resize (ps->hardLimit * COORD_COMPONENTS); | ||
143 | 299 | |||
144 | 300 | if (ps->colors_cache.size () < (unsigned int)ps->hardLimit * COLOR_COMPONENTS) | ||
145 | 301 | ps->colors_cache.resize (ps->hardLimit * COLOR_COMPONENTS); | ||
146 | 302 | |||
147 | 303 | if (ps->darken > 0) | ||
148 | 304 | if (ps->dcolors_cache.size () < (unsigned int)ps->hardLimit * COLOR_COMPONENTS) | ||
149 | 305 | ps->dcolors_cache.resize (ps->hardLimit * COLOR_COMPONENTS); | ||
150 | 283 | 306 | ||
151 | 284 | glEnable (GL_BLEND); | 307 | glEnable (GL_BLEND); |
152 | 308 | |||
153 | 285 | if (ps->tex) | 309 | if (ps->tex) |
154 | 286 | { | 310 | { |
155 | 287 | glBindTexture (GL_TEXTURE_2D, ps->tex); | 311 | glBindTexture (GL_TEXTURE_2D, ps->tex); |
156 | 288 | glEnable (GL_TEXTURE_2D); | 312 | glEnable (GL_TEXTURE_2D); |
157 | 289 | } | 313 | } |
210 | 290 | glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 314 | |
211 | 291 | 315 | i = j = k = l = 0; | |
160 | 292 | /* Check that the cache is big enough */ | ||
161 | 293 | if (ps->hardLimit > ps->vertex_cache_count) | ||
162 | 294 | { | ||
163 | 295 | ps->vertices_cache = | ||
164 | 296 | (GLfloat*) realloc (ps->vertices_cache, | ||
165 | 297 | ps->hardLimit * 4 * 3 * sizeof (GLfloat)); | ||
166 | 298 | ps->vertex_cache_count = ps->hardLimit; | ||
167 | 299 | } | ||
168 | 300 | |||
169 | 301 | if (ps->hardLimit > ps->coords_cache_count) | ||
170 | 302 | { | ||
171 | 303 | ps->coords_cache = | ||
172 | 304 | (GLfloat*) realloc (ps->coords_cache, | ||
173 | 305 | ps->hardLimit * 4 * 2 * sizeof (GLfloat)); | ||
174 | 306 | ps->coords_cache_count = ps->hardLimit; | ||
175 | 307 | } | ||
176 | 308 | |||
177 | 309 | if (ps->hardLimit > ps->color_cache_count) | ||
178 | 310 | { | ||
179 | 311 | ps->colors_cache = | ||
180 | 312 | (GLfloat*) realloc (ps->colors_cache, | ||
181 | 313 | ps->hardLimit * 4 * 4 * sizeof (GLfloat)); | ||
182 | 314 | ps->color_cache_count = ps->hardLimit; | ||
183 | 315 | } | ||
184 | 316 | |||
185 | 317 | if (ps->darken > 0) | ||
186 | 318 | { | ||
187 | 319 | if (ps->dcolors_cache_count < ps->hardLimit) | ||
188 | 320 | { | ||
189 | 321 | ps->dcolors_cache = | ||
190 | 322 | (GLfloat*) realloc (ps->dcolors_cache, | ||
191 | 323 | ps->hardLimit * 4 * 4 * sizeof (GLfloat)); | ||
192 | 324 | ps->dcolors_cache_count = ps->hardLimit; | ||
193 | 325 | } | ||
194 | 326 | } | ||
195 | 327 | |||
196 | 328 | GLfloat *dcolors = ps->dcolors_cache; | ||
197 | 329 | GLfloat *vertices = ps->vertices_cache; | ||
198 | 330 | GLfloat *coords = ps->coords_cache; | ||
199 | 331 | GLfloat *colors = ps->colors_cache; | ||
200 | 332 | |||
201 | 333 | int cornersSize = sizeof (GLfloat) * 8; | ||
202 | 334 | int colorSize = sizeof (GLfloat) * 4; | ||
203 | 335 | |||
204 | 336 | GLfloat cornerCoords[8] = {0.0, 0.0, | ||
205 | 337 | 0.0, 1.0, | ||
206 | 338 | 1.0, 1.0, | ||
207 | 339 | 1.0, 0.0}; | ||
208 | 340 | |||
209 | 341 | int numActive = 0; | ||
212 | 342 | 316 | ||
213 | 343 | Particle *part = ps->particles; | 317 | Particle *part = ps->particles; |
216 | 344 | int i; | 318 | int m; |
217 | 345 | for (i = 0; i < ps->hardLimit; i++, part++) | 319 | for (m = 0; m < ps->hardLimit; m++, part++) |
218 | 346 | { | 320 | { |
219 | 347 | if (part->t > 0.0f) | 321 | if (part->t > 0.0f) |
220 | 348 | { | 322 | { |
221 | 349 | numActive += 4; | ||
222 | 350 | |||
223 | 351 | float cOff = part->s / 2.; //Corner offset from center | 323 | float cOff = part->s / 2.; //Corner offset from center |
224 | 352 | 324 | ||
225 | 353 | if (part->t > ps->tnew) //New particles start larger | 325 | if (part->t > ps->tnew) //New particles start larger |
226 | @@ -360,88 +332,167 @@ | |||
227 | 360 | float offA = cOff * (cos (part->phi) - sin (part->phi)); | 332 | float offA = cOff * (cos (part->phi) - sin (part->phi)); |
228 | 361 | float offB = cOff * (cos (part->phi) + sin (part->phi)); | 333 | float offB = cOff * (cos (part->phi) + sin (part->phi)); |
229 | 362 | 334 | ||
255 | 363 | vertices[0] = part->x - offB; | 335 | GLushort r, g, b, a, dark_a; |
256 | 364 | vertices[1] = part->y - offA; | 336 | |
257 | 365 | vertices[2] = 0; | 337 | r = part->c[0] * 65535.0f; |
258 | 366 | 338 | g = part->c[1] * 65535.0f; | |
259 | 367 | vertices[3] = part->x - offA; | 339 | b = part->c[2] * 65535.0f; |
235 | 368 | vertices[4] = part->y + offB; | ||
236 | 369 | vertices[5] = 0; | ||
237 | 370 | |||
238 | 371 | vertices[6] = part->x + offB; | ||
239 | 372 | vertices[7] = part->y + offA; | ||
240 | 373 | vertices[8] = 0; | ||
241 | 374 | |||
242 | 375 | vertices[9] = part->x + offA; | ||
243 | 376 | vertices[10] = part->y - offB; | ||
244 | 377 | vertices[11] = 0; | ||
245 | 378 | |||
246 | 379 | vertices += 12; | ||
247 | 380 | |||
248 | 381 | memcpy (coords, cornerCoords, cornersSize); | ||
249 | 382 | |||
250 | 383 | coords += 8; | ||
251 | 384 | |||
252 | 385 | colors[0] = part->c[0]; | ||
253 | 386 | colors[1] = part->c[1]; | ||
254 | 387 | colors[2] = part->c[2]; | ||
260 | 388 | 340 | ||
261 | 389 | if (part->t > ps->tnew) //New particles start at a == 1 | 341 | if (part->t > ps->tnew) //New particles start at a == 1 |
264 | 390 | colors[3] = part->a + (1. - part->a) * (part->t - ps->tnew) | 342 | a = part->a + (1. - part->a) * (part->t - ps->tnew) |
265 | 391 | / (1. - ps->tnew); | 343 | / (1. - ps->tnew) * 65535.0f; |
266 | 392 | else if (part->t < ps->told) //Old particles fade to a = 0 | 344 | else if (part->t < ps->told) //Old particles fade to a = 0 |
268 | 393 | colors[3] = part->a * part->t / ps->told; | 345 | a = part->a * part->t / ps->told * 65535.0f; |
269 | 394 | else //The others have their own a | 346 | else //The others have their own a |
277 | 395 | colors[3] = part->a; | 347 | a = part->a * 65535.0f; |
278 | 396 | 348 | ||
279 | 397 | memcpy (colors + 4, colors, colorSize); | 349 | dark_a = a * ps->darken; |
280 | 398 | memcpy (colors + 8, colors, colorSize); | 350 | |
281 | 399 | memcpy (colors + 12, colors, colorSize); | 351 | //first triangle |
282 | 400 | 352 | ps->vertices_cache[i + 0] = part->x - offB; | |
283 | 401 | colors += 16; | 353 | ps->vertices_cache[i + 1] = part->y - offA; |
284 | 354 | ps->vertices_cache[i + 2] = 0; | ||
285 | 355 | |||
286 | 356 | ps->vertices_cache[i + 3] = part->x - offA; | ||
287 | 357 | ps->vertices_cache[i + 4] = part->y + offB; | ||
288 | 358 | ps->vertices_cache[i + 5] = 0; | ||
289 | 359 | |||
290 | 360 | ps->vertices_cache[i + 6] = part->x + offB; | ||
291 | 361 | ps->vertices_cache[i + 7] = part->y + offA; | ||
292 | 362 | ps->vertices_cache[i + 8] = 0; | ||
293 | 363 | |||
294 | 364 | //second triangle | ||
295 | 365 | ps->vertices_cache[i + 9] = part->x + offB; | ||
296 | 366 | ps->vertices_cache[i + 10] = part->y + offA; | ||
297 | 367 | ps->vertices_cache[i + 11] = 0; | ||
298 | 368 | |||
299 | 369 | ps->vertices_cache[i + 12] = part->x + offA; | ||
300 | 370 | ps->vertices_cache[i + 13] = part->y - offB; | ||
301 | 371 | ps->vertices_cache[i + 14] = 0; | ||
302 | 372 | |||
303 | 373 | ps->vertices_cache[i + 15] = part->x - offB; | ||
304 | 374 | ps->vertices_cache[i + 16] = part->y - offA; | ||
305 | 375 | ps->vertices_cache[i + 17] = 0; | ||
306 | 376 | |||
307 | 377 | i += 18; | ||
308 | 378 | |||
309 | 379 | ps->coords_cache[j + 0] = 0.0; | ||
310 | 380 | ps->coords_cache[j + 1] = 0.0; | ||
311 | 381 | |||
312 | 382 | ps->coords_cache[j + 2] = 0.0; | ||
313 | 383 | ps->coords_cache[j + 3] = 1.0; | ||
314 | 384 | |||
315 | 385 | ps->coords_cache[j + 4] = 1.0; | ||
316 | 386 | ps->coords_cache[j + 5] = 1.0; | ||
317 | 387 | |||
318 | 388 | //second | ||
319 | 389 | ps->coords_cache[j + 6] = 1.0; | ||
320 | 390 | ps->coords_cache[j + 7] = 1.0; | ||
321 | 391 | |||
322 | 392 | ps->coords_cache[j + 8] = 1.0; | ||
323 | 393 | ps->coords_cache[j + 9] = 0.0; | ||
324 | 394 | |||
325 | 395 | ps->coords_cache[j + 10] = 0.0; | ||
326 | 396 | ps->coords_cache[j + 11] = 0.0; | ||
327 | 397 | |||
328 | 398 | j += 12; | ||
329 | 399 | |||
330 | 400 | ps->colors_cache[k + 0] = r; | ||
331 | 401 | ps->colors_cache[k + 1] = g; | ||
332 | 402 | ps->colors_cache[k + 2] = b; | ||
333 | 403 | ps->colors_cache[k + 3] = a; | ||
334 | 404 | |||
335 | 405 | ps->colors_cache[k + 4] = r; | ||
336 | 406 | ps->colors_cache[k + 5] = g; | ||
337 | 407 | ps->colors_cache[k + 6] = b; | ||
338 | 408 | ps->colors_cache[k + 7] = a; | ||
339 | 409 | |||
340 | 410 | ps->colors_cache[k + 8] = r; | ||
341 | 411 | ps->colors_cache[k + 9] = g; | ||
342 | 412 | ps->colors_cache[k + 10] = b; | ||
343 | 413 | ps->colors_cache[k + 11] = a; | ||
344 | 414 | |||
345 | 415 | //second | ||
346 | 416 | ps->colors_cache[k + 12] = r; | ||
347 | 417 | ps->colors_cache[k + 13] = g; | ||
348 | 418 | ps->colors_cache[k + 14] = b; | ||
349 | 419 | ps->colors_cache[k + 15] = a; | ||
350 | 420 | |||
351 | 421 | ps->colors_cache[k + 16] = r; | ||
352 | 422 | ps->colors_cache[k + 17] = g; | ||
353 | 423 | ps->colors_cache[k + 18] = b; | ||
354 | 424 | ps->colors_cache[k + 19] = a; | ||
355 | 425 | |||
356 | 426 | ps->colors_cache[k + 20] = r; | ||
357 | 427 | ps->colors_cache[k + 21] = g; | ||
358 | 428 | ps->colors_cache[k + 22] = b; | ||
359 | 429 | ps->colors_cache[k + 23] = a; | ||
360 | 430 | |||
361 | 431 | k += 24; | ||
362 | 402 | 432 | ||
363 | 403 | if (ps->darken > 0) | 433 | if (ps->darken > 0) |
364 | 404 | { | 434 | { |
374 | 405 | dcolors[0] = colors[0]; | 435 | ps->dcolors_cache[l + 0] = r; |
375 | 406 | dcolors[1] = colors[1]; | 436 | ps->dcolors_cache[l + 1] = g; |
376 | 407 | dcolors[2] = colors[2]; | 437 | ps->dcolors_cache[l + 2] = b; |
377 | 408 | dcolors[3] = colors[3] * ps->darken; | 438 | ps->dcolors_cache[l + 3] = dark_a; |
378 | 409 | memcpy (dcolors + 4, dcolors, colorSize); | 439 | |
379 | 410 | memcpy (dcolors + 8, dcolors, colorSize); | 440 | ps->dcolors_cache[l + 4] = r; |
380 | 411 | memcpy (dcolors + 12, dcolors, colorSize); | 441 | ps->dcolors_cache[l + 5] = g; |
381 | 412 | 442 | ps->dcolors_cache[l + 6] = b; | |
382 | 413 | dcolors += 16; | 443 | ps->dcolors_cache[l + 7] = dark_a; |
383 | 444 | |||
384 | 445 | ps->dcolors_cache[l + 8] = r; | ||
385 | 446 | ps->dcolors_cache[l + 9] = g; | ||
386 | 447 | ps->dcolors_cache[l + 10] = b; | ||
387 | 448 | ps->dcolors_cache[l + 11] = dark_a; | ||
388 | 449 | |||
389 | 450 | //second | ||
390 | 451 | ps->dcolors_cache[l + 12] = r; | ||
391 | 452 | ps->dcolors_cache[l + 13] = g; | ||
392 | 453 | ps->dcolors_cache[l + 14] = b; | ||
393 | 454 | ps->dcolors_cache[l + 15] = dark_a; | ||
394 | 455 | |||
395 | 456 | ps->dcolors_cache[l + 16] = r; | ||
396 | 457 | ps->dcolors_cache[l + 17] = g; | ||
397 | 458 | ps->dcolors_cache[l + 18] = b; | ||
398 | 459 | ps->dcolors_cache[l + 19] = dark_a; | ||
399 | 460 | |||
400 | 461 | ps->dcolors_cache[l + 20] = r; | ||
401 | 462 | ps->dcolors_cache[l + 21] = g; | ||
402 | 463 | ps->dcolors_cache[l + 22] = b; | ||
403 | 464 | ps->dcolors_cache[l + 23] = dark_a; | ||
404 | 465 | |||
405 | 466 | l += 24; | ||
406 | 414 | } | 467 | } |
407 | 415 | } | 468 | } |
408 | 416 | } | 469 | } |
417 | 417 | glEnableClientState (GL_VERTEX_ARRAY); | 470 | |
418 | 418 | glEnableClientState (GL_TEXTURE_COORD_ARRAY); | 471 | GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer (); |
419 | 419 | glEnableClientState (GL_COLOR_ARRAY); | 472 | |
412 | 420 | |||
413 | 421 | glTexCoordPointer (2, GL_FLOAT, 2 * sizeof (GLfloat), ps->coords_cache); | ||
414 | 422 | glVertexPointer (3, GL_FLOAT, 3 * sizeof (GLfloat), ps->vertices_cache); | ||
415 | 423 | |||
416 | 424 | // darken the background | ||
420 | 425 | if (ps->darken > 0) | 473 | if (ps->darken > 0) |
421 | 426 | { | 474 | { |
422 | 427 | glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); | 475 | glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); |
425 | 428 | glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), ps->dcolors_cache); | 476 | stream->begin (GL_TRIANGLES); |
426 | 429 | glDrawArrays (GL_QUADS, 0, numActive); | 477 | stream->addVertices (i / 3, &ps->vertices_cache[0]); |
427 | 478 | stream->addTexCoords (0, j / 2, &ps->coords_cache[0]); | ||
428 | 479 | stream->addColors (l / 4, &ps->dcolors_cache[0]); | ||
429 | 480 | |||
430 | 481 | if (stream->end ()) | ||
431 | 482 | stream->render (transform); | ||
432 | 430 | } | 483 | } |
434 | 431 | // draw particles | 484 | |
435 | 485 | /* draw particles */ | ||
436 | 432 | glBlendFunc (GL_SRC_ALPHA, ps->blendMode); | 486 | glBlendFunc (GL_SRC_ALPHA, ps->blendMode); |
449 | 433 | 487 | stream->begin (GL_TRIANGLES); | |
450 | 434 | glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), ps->colors_cache); | 488 | |
451 | 435 | 489 | stream->addVertices (i / 3, &ps->vertices_cache[0]); | |
452 | 436 | glDrawArrays (GL_QUADS, 0, numActive); | 490 | stream->addTexCoords (0, j / 2, &ps->coords_cache[0]); |
453 | 437 | 491 | stream->addColors (k / 4, &ps->colors_cache[0]); | |
454 | 438 | glDisableClientState (GL_COLOR_ARRAY); | 492 | |
455 | 439 | glDisableClientState (GL_TEXTURE_COORD_ARRAY); | 493 | if (stream->end ()) |
456 | 440 | glDisableClientState (GL_VERTEX_ARRAY); | 494 | stream->render (transform); |
457 | 441 | 495 | ||
446 | 442 | glPopMatrix (); | ||
447 | 443 | glColor4usv (defaultColor); | ||
448 | 444 | gScreen->setTexEnvMode (GL_REPLACE); | ||
458 | 445 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | 496 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
459 | 446 | glDisable (GL_TEXTURE_2D); | 497 | glDisable (GL_TEXTURE_2D); |
460 | 447 | glDisable (GL_BLEND); | 498 | glDisable (GL_BLEND); |
461 | @@ -537,16 +588,9 @@ | |||
462 | 537 | if (ps->tex) | 588 | if (ps->tex) |
463 | 538 | glDeleteTextures (1, &ps->tex); | 589 | glDeleteTextures (1, &ps->tex); |
464 | 539 | 590 | ||
465 | 540 | if (ps->vertices_cache) | ||
466 | 541 | free (ps->vertices_cache); | ||
467 | 542 | if (ps->colors_cache) | ||
468 | 543 | free (ps->colors_cache); | ||
469 | 544 | if (ps->coords_cache) | ||
470 | 545 | free (ps->coords_cache); | ||
471 | 546 | if (ps->dcolors_cache) | ||
472 | 547 | free (ps->dcolors_cache); | ||
473 | 548 | } | 591 | } |
474 | 549 | 592 | ||
475 | 593 | |||
476 | 550 | static void | 594 | static void |
477 | 551 | genNewParticles (ParticleSystem *ps, Emitter *e) | 595 | genNewParticles (ParticleSystem *ps, Emitter *e) |
478 | 552 | { | 596 | { |
479 | @@ -874,26 +918,15 @@ | |||
480 | 874 | CompOutput *output, | 918 | CompOutput *output, |
481 | 875 | unsigned int mask) | 919 | unsigned int mask) |
482 | 876 | { | 920 | { |
487 | 877 | bool status; | 921 | bool status = gScreen->glPaintOutput (sa, transform, region, output, mask); |
488 | 878 | GLMatrix sTransform; | 922 | GLMatrix sTransform = transform; |
485 | 879 | |||
486 | 880 | status = gScreen->glPaintOutput (sa, transform, region, output, mask); | ||
489 | 881 | 923 | ||
490 | 882 | if (!ps || !ps->active) | 924 | if (!ps || !ps->active) |
491 | 883 | return status; | 925 | return status; |
492 | 884 | 926 | ||
493 | 885 | sTransform.reset (); | ||
494 | 886 | |||
495 | 887 | sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); | 927 | sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); |
496 | 888 | 928 | ||
505 | 889 | glPushMatrix (); | 929 | drawParticles (ps, sTransform); |
498 | 890 | glLoadMatrixf (sTransform.getMatrix ()); | ||
499 | 891 | |||
500 | 892 | drawParticles (ps); | ||
501 | 893 | |||
502 | 894 | glPopMatrix (); | ||
503 | 895 | |||
504 | 896 | glColor4usv (defaultColor); | ||
506 | 897 | 930 | ||
507 | 898 | return status; | 931 | return status; |
508 | 899 | } | 932 | } |
Hey Michail !
LGTM @ a first glance. I will test this ASAP (on OpenGL hw). :)
But knowing you, I'm sure it is perfect ;)
The merge of this might take a while though, as the release of 0.9.10.0 gets prepared currently...