24
24
COMPIZ_PLUGIN_20090315 (firepaint, FirePluginVTable);
26
26
/* 3 vertices per triangle, 2 triangles per particle */
27
const unsigned short CACHESIZE_FACTOR = 3 * 2;
27
const unsigned short CACHESIZE_FACTOR = 3 * 2;
29
28
/* 2 coordinates, x and y */
30
const unsigned short COORD_COMPONENTS = CACHESIZE_FACTOR * 2;
29
const unsigned short COORD_COMPONENTS = CACHESIZE_FACTOR * 2;
32
30
/* each vertex is stored as 3 GLfloats */
33
31
const unsigned short VERTEX_COMPONENTS = CACHESIZE_FACTOR * 3;
35
32
/* 4 colors, RGBA */
36
const unsigned short COLOR_COMPONENTS = CACHESIZE_FACTOR * 4;
33
const unsigned short COLOR_COMPONENTS = CACHESIZE_FACTOR * 4;
38
35
Particle::Particle () :
134
134
i = j = k = l = 0;
137
GLfloat xMinusW, xPlusW, yMinusH, yPlusH;
138
GLushort r, g, b, a, dark_a;
136
140
/* for each particle, use two triangles to display it */
137
141
foreach (Particle &part, particles)
139
143
if (part.life > 0.0f)
141
float w = part.width / 2;
142
float h = part.height / 2;
144
GLushort r, g, b, a, dark_a;
145
w = part.width / 2.0f;
146
h = part.height / 2.0f;
146
148
r = part.r * 65535.0f;
147
149
g = part.g * 65535.0f;
148
150
b = part.b * 65535.0f;
149
a = part.life * part.a * 65535.0f;
150
dark_a = part.life * part.a * darken * 65535.0f;
152
w += (w * part.w_mod) * part.life;
153
h += (h * part.h_mod) * part.life;
151
a = part.life * part.a * 65535.0f;
152
dark_a = part.life * part.a * 65535.0f * darken;
154
w += w * part.w_mod * part.life;
155
h += h * part.h_mod * part.life;
157
xMinusW = part.x - w;
160
yMinusH = part.y - h;
156
vertices_cache[i + 0] = part.x - w;
157
vertices_cache[i + 1] = part.y - h;
164
vertices_cache[i + 0] = xMinusW;
165
vertices_cache[i + 1] = yMinusH;
158
166
vertices_cache[i + 2] = part.z;
160
vertices_cache[i + 3] = part.x - w;
161
vertices_cache[i + 4] = part.y + h;
168
vertices_cache[i + 3] = xMinusW;
169
vertices_cache[i + 4] = yPlusH;
162
170
vertices_cache[i + 5] = part.z;
164
vertices_cache[i + 6] = part.x + w;
165
vertices_cache[i + 7] = part.y + h;
172
vertices_cache[i + 6] = xPlusW;
173
vertices_cache[i + 7] = yPlusH;
166
174
vertices_cache[i + 8] = part.z;
168
176
//second triangle
169
vertices_cache[i + 9] = part.x + w;
170
vertices_cache[i + 10] = part.y + h;
177
vertices_cache[i + 9] = xPlusW;
178
vertices_cache[i + 10] = yPlusH;
171
179
vertices_cache[i + 11] = part.z;
173
vertices_cache[i + 12] = part.x + w;
174
vertices_cache[i + 13] = part.y - h;
181
vertices_cache[i + 12] = xPlusW;
182
vertices_cache[i + 13] = yMinusH;
175
183
vertices_cache[i + 14] = part.z;
177
vertices_cache[i + 15] = part.x - w;
178
vertices_cache[i + 16] = part.y - h;
185
vertices_cache[i + 15] = xMinusW;
186
vertices_cache[i + 16] = yMinusH;
179
187
vertices_cache[i + 17] = part.z;
306
ParticleSystem::updateParticles (float time)
314
ParticleSystem::updateParticles (float time)
308
float speed = (time / 50.0);
309
float f_slowdown = slowdown * (1 - MAX (0.99, time / 1000.0) ) * 1000;
316
float speed = (time / 50.0);
317
float f_slowdown = slowdown * (1 - MAX (0.99, time / 1000.0)) * 1000;
376
381
CompAction::State state,
377
382
CompOption::Vector options)
381
x = CompOption::getFloatOptionNamed (options, "x", 0);
382
y = CompOption::getFloatOptionNamed (options, "y", 0);
384
float x = CompOption::getFloatOptionNamed (options, "x", 0);
385
float y = CompOption::getFloatOptionNamed (options, "y", 0);
384
387
fireAddPoint (x, y, false);
394
397
CompOption::Vector options)
396
399
if (screen->otherGrabExist (NULL))
400
grabIndex = screen->pushGrab (None, "firepaint");
403
grabIndex = screen->pushGrab (None, "firepaint");
402
405
if (state & CompAction::StateInitButton)
403
action->setState (action->state () | CompAction::StateTermButton);
406
action->setState (action->state () | CompAction::StateTermButton);
405
408
if (state & CompAction::StateInitKey)
406
action->setState (action->state () | CompAction::StateTermKey);
409
action->setState (action->state () | CompAction::StateTermKey);
408
411
fireAddPoint (pointerX, pointerY, true);
526
part.r = (float) optionGetFireColorRed () / 0xffff -
528
(float) optionGetFireColorRed () / 0xffff);
529
part.g = (float) optionGetFireColorGreen () / 0xffff -
531
(float) optionGetFireColorGreen () / 0xffff);
532
part.b = (float) optionGetFireColorBlue () / 0xffff -
534
(float) optionGetFireColorBlue () / 0xffff);
526
part.r = optionGetFireColorRed () / 0xffff -
527
(rVal / 1.7 * optionGetFireColorRed () / 0xffff);
528
part.g = optionGetFireColorGreen () / 0xffff -
529
(rVal / 1.7 * optionGetFireColorGreen () / 0xffff);
530
part.b = optionGetFireColorBlue () / 0xffff -
531
(rVal / 1.7 * optionGetFireColorBlue () / 0xffff);
537
534
/* set transparency */
582
575
FireScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
583
const GLMatrix &transform,
584
const CompRegion ®ion,
576
const GLMatrix &transform,
577
const CompRegion ®ion,
590
status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
592
if ( (!init && ps.active) || brightness < 1.0)
581
bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
583
if ((!init && ps.active) || brightness < 1.0)
594
585
GLMatrix sTransform = transform;
636
626
colors[i*4+3] = (1.0 - brightness) * 65535.0f;
639
GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
629
GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
630
GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);
641
635
stream->begin (GL_TRIANGLES);
642
636
stream->addVertices (6, vertices);
643
637
stream->addColors (6, colors);