2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
/******************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
27
******************************************************************************/
33
#include "applet-struct.h"
34
#include "applet-wave.h"
37
void cd_animations_init_wave (CDAnimationData *pData)
39
pData->pCoords[0] = .5;
40
pData->pCoords[1] = .5;
42
pData->pVertices[0] = 0.;
43
pData->pVertices[1] = 0.;
44
pData->pVertices[2] = 0.;
45
pData->fWavePosition = - myConfig.fWaveWidth / 2;
47
pData->iNumActiveNodes = 6;
48
pData->pVertices[3*1+0] = -.5;
49
pData->pVertices[3*1+1] = -.5;
50
pData->pVertices[3*2+0] = .5;
51
pData->pVertices[3*2+1] = -.5;
52
pData->pVertices[3*3+0] = .5;
53
pData->pVertices[3*3+1] = .5;
54
pData->pVertices[3*4+0] = -.5;
55
pData->pVertices[3*4+1] = .5;
56
pData->pVertices[3*5+0] = -.5;
57
pData->pVertices[3*5+1] = -.5;
58
pData->pCoords[2*1+0] = 0.;
59
pData->pCoords[2*1+1] = 1.;
60
pData->pCoords[2*2+0] = 1.;
61
pData->pCoords[2*2+1] = 1.;
62
pData->pCoords[2*3+0] = 1.;
63
pData->pCoords[2*3+1] = 0.;
64
pData->pCoords[2*4+0] = 0.;
65
pData->pCoords[2*4+1] = 0.;
66
pData->pCoords[2*5+0] = 0.;
67
pData->pCoords[2*5+1] = 1.;
68
pData->bIsWaving = TRUE;
72
gboolean cd_animations_update_wave (CDAnimationData *pData, double dt)
74
GLfloat *pVertices = &pData->pVertices[3];
75
GLfloat *pCoords = &pData->pCoords[2];
76
double x, y, a, a_, x_;
77
double p = pData->fWavePosition, w = myConfig.fWaveWidth;
78
int n = (CD_WAVE_NB_POINTS - 1) / 2; // nbre de points pour une demi-vague.
80
for (i = 0; i < CD_WAVE_NB_POINTS; i ++)
86
a_ = 1. * (i+1-n) / (n-1);
88
if (x_ > 0) // le point suivant est dedans.
90
y = myConfig.fWaveAmplitude * cos (G_PI/2 * a + x / (w/2) * G_PI/2);
102
else if (i == CD_WAVE_NB_POINTS-1)
106
a_ = 1. * (i-1-n) / (n-1);
108
if (x_ < 1) // le point precedent est dedans.
110
y = myConfig.fWaveAmplitude * cos (G_PI/2 * a - (x-1) / (w/2) * G_PI/2);
124
a = 1. * (i-n) / (n-1);
128
a_ = 1. * (i+1-n) / (n-1);
130
if (x_ > 0) // le point suivant est dedans.
132
y = myConfig.fWaveAmplitude * cos (G_PI/2 * a - x / (w/2) * G_PI/2);
140
a_ = 1. * (i-1-n) / (n-1);
142
if (x_ < 1) // le point precedent est dedans.
144
y = myConfig.fWaveAmplitude * cos (G_PI/2 * a - (x-1) / (w/2) * G_PI/2);
151
y = myConfig.fWaveAmplitude * cos (G_PI/2 * a);
157
pVertices[3*j] = -.5 - y;
158
pVertices[3*j+1] = .5 - x;
159
pVertices[3*j+2] = 0.;
164
for (i = 0; i < j; i ++)
168
pCoords[2*k+1] = pCoords[2*i+1];
170
pVertices[3*k] = - pVertices[3*i];
171
pVertices[3*k+1] = pVertices[3*i+1];
172
pVertices[3*k+2] = 0.;
177
pCoords[2*j] = pCoords[0];
178
pCoords[2*j+1] = pCoords[1];
180
pVertices[3*j] = pVertices[0];
181
pVertices[3*j+1] = pVertices[1];
182
pVertices[3*j+2] = 0.;
184
pData->fWavePosition += dt / myConfig.iWaveDuration;
185
pData->iNumActiveNodes = j + 2;
186
return (pData->fWavePosition - w/2 < 1);
189
void cd_animations_draw_wave_icon (Icon *pIcon, CairoDock *pDock, CDAnimationData *pData)
192
cairo_dock_set_icon_scale (pIcon, pDock, 1.);
194
glColor4f (1., 1., 1., pIcon->fAlpha);
196
if (pIcon->fAlpha == 1)
197
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
199
_cairo_dock_set_blend_alpha ();
201
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
203
glEnable(GL_TEXTURE_2D); // Je veux de la texture
204
glBindTexture(GL_TEXTURE_2D, pIcon->iIconTexture);
205
glPolygonMode(GL_FRONT, GL_FILL);
207
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
208
glEnableClientState (GL_VERTEX_ARRAY);
210
glTexCoordPointer (2, GL_FLOAT, 0, pData->pCoords);
211
glVertexPointer (3, GL_FLOAT, 0, pData->pVertices);
213
glDrawArrays (GL_TRIANGLE_FAN, 0, pData->iNumActiveNodes);
217
if (pDock->bUseReflect)
220
double x0, y0, x1, y1;
221
double fReflectRatio = myIcons.fReflectSize * pDock->fRatio / pIcon->fHeight / pIcon->fScale;
222
double fOffsetY = pIcon->fHeight * pIcon->fScale/2 + (myIcons.fReflectSize/2 + pIcon->fDeltaYReflection) * pDock->fRatio;
223
if (pDock->bHorizontalDock)
225
if (pDock->bDirectionUp)
227
fOffsetY = pIcon->fHeight * pIcon->fScale + pIcon->fDeltaYReflection;
228
glTranslatef (0., - fOffsetY, 0.);
229
glScalef (pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, - pIcon->fHeight * pIcon->fScale, 1.); // taille du reflet et on se retourne.
231
y0 = 1. - fReflectRatio;
237
glTranslatef (0., fOffsetY, 0.);
238
glScalef (pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, myIcons.fReflectSize * pDock->fRatio, 1.);
247
if (pDock->bDirectionUp)
249
glTranslatef (fOffsetY, 0., 0.);
250
glScalef (- myIcons.fReflectSize * pDock->fRatio, pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, 1.);
251
x0 = 1. - fReflectRatio;
258
glTranslatef (- fOffsetY, 0., 0.);
259
glScalef (myIcons.fReflectSize * pDock->fRatio, pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, 1.);
266
//glEnableClientState(GL_COLOR_ARRAY);
268
//glColorPointer(4, GL_FLOAT, 0, pData->pColors);
269
//glDrawArrays (GL_TRIANGLE_FAN, 0, pData->iNumActiveNodes);
271
//glDisableClientState(GL_COLOR_ARRAY);
274
glActiveTexture(GL_TEXTURE0_ARB); // Go pour le multitexturing 1ere passe
275
glEnable(GL_TEXTURE_2D); // On active le texturing sur cette passe
276
glBindTexture(GL_TEXTURE_2D, pIcon->iIconTexture);
278
glColor4f(1., 1., 1., myIcons.fAlbedo * pIcon->fAlpha); // transparence du reflet.
281
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
283
glActiveTexture(GL_TEXTURE1_ARB); // Go pour le texturing 2eme passe
284
glEnable(GL_TEXTURE_2D);
285
glBindTexture(GL_TEXTURE_2D, g_pGradationTexture[pDock->bHorizontalDock]);
286
glColor4f(1., 1., 1., 1.); // transparence du reflet.
288
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
289
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // Le mode de combinaison des textures
290
glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); // multiplier les alpha.
291
/*glEnable(GL_TEXTURE_GEN_S); // generation texture en S
292
glEnable(GL_TEXTURE_GEN_T); // et en T
293
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); // la je veux un mapping tout ce qu'il y a de plus classique
294
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);*/
295
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
296
glEnableClientState (GL_VERTEX_ARRAY);
298
glTexCoordPointer (2, GL_FLOAT, 0, pData->pCoords);
299
glVertexPointer (3, GL_FLOAT, 0, pData->pVertices);
301
glDrawArrays (GL_TRIANGLE_FAN, 0, pData->iNumActiveNodes);
303
glActiveTexture(GL_TEXTURE1_ARB);
304
glDisable(GL_TEXTURE_2D);
305
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
306
glDisableClientState (GL_VERTEX_ARRAY);
307
glDisable(GL_TEXTURE_GEN_S);
308
glDisable(GL_TEXTURE_GEN_T);
309
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
310
glActiveTexture(GL_TEXTURE0_ARB);
311
glDisable(GL_TEXTURE_2D);
312
glDisable(GL_TEXTURE_GEN_S);
313
glDisable(GL_TEXTURE_GEN_T);
318
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
319
glDisableClientState (GL_VERTEX_ARRAY);
320
glDisable (GL_TEXTURE_2D);
321
glDisable (GL_BLEND);