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-mesh-factory.h"
36
#define RADIAN (G_PI / 180.0) // Conversion Radian/Degres
38
GLuint cairo_dock_load_capsule_calllist (void)
40
GLuint iCallList = glGenLists (1);
41
int deg, deg2, iter, nb_iter=20;
42
float amp, rayon, c=2.;
48
glNewList(iCallList, GL_COMPILE); // Go pour la compilation de la display list
49
glPolygonMode (GL_FRONT, GL_FILL);
51
/**glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); // ok la on selectionne le type de generation des coordonnees de la texture
52
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
53
glTexGenfv(GL_S, GL_OBJECT_PLANE, fCapsuleObjectPlaneS); // On place la texture correctement en X
54
glTexGenfv(GL_T, GL_OBJECT_PLANE, fCapsuleObjectPlaneT); // Et en Y
55
glEnable(GL_TEXTURE_GEN_S); // oui je veux une generation en S
56
glEnable(GL_TEXTURE_GEN_T); // Et en T aussi
58
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // pour les bouts de textures qui depassent.
59
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);*/
61
glMatrixMode(GL_TEXTURE); // On selectionne la matrice des textures
63
glLoadIdentity(); // On la reset
64
glTranslatef(0.5f, 0.5f, 0.); // Et on decale la texture pour un affiche propre
65
glRotatef (180, 1, 0, 0); // sinon les icones sont a l'envers.
66
glMatrixMode(GL_MODELVIEW); // On revient sur la matrice d'affichage
68
// bon la je commente pas on fait juste une demi sphere applatie
69
double a = .5/c; // applatissement;
70
double b = 1./nb_iter;
71
double xab, yab, zab, xac, yac, zac, nx, ny, nz, n;
74
for (iter = 0;iter < nb_iter-1;iter ++)
76
for (deg = 0;deg < 360;deg += 10)
78
xab = b * cos(deg*RADIAN);
79
yab = b * sin(deg*RADIAN);
80
zab = a * sin(deg2*RADIAN) - a * sin((deg2+amp)*RADIAN);
81
//zab = a*cos (deg2*RADIAN) * amp*RADIAN;
82
xac = rayon * cos((deg+10)*RADIAN) - (rayon-b) * cos(deg*RADIAN);
83
yac = rayon * sin((deg+10)*RADIAN) - (rayon-b) * sin(deg*RADIAN);
84
zac = a * sin(deg2*RADIAN) - a * sin((deg2+amp)*RADIAN);
85
//zac = a * sin((deg2+amp)*RADIAN) - a * sin(deg2*RADIAN);
86
nx = yab*zac - zab*yac;
87
ny = zab*xac - xab*zac;
88
nz = xab*yac - yab*xac;
89
n = sqrt (nx*nx + ny*ny + nz*nz);
91
glNormal3f (nx/n, ny/n, nz/n);
93
glVertex3f((rayon-b) * cos(deg*RADIAN),
94
(rayon-b) * sin(deg*RADIAN),
95
a * sin((deg2+amp)*RADIAN) + 0.1f/c);
96
glVertex3f(rayon * cos(deg*RADIAN),
97
rayon * sin(deg*RADIAN),
98
a * sin(deg2*RADIAN) + 0.1f/c);
99
glVertex3f(rayon * cos((deg+10)*RADIAN),
100
rayon * sin((deg+10)*RADIAN),
101
a * sin(deg2*RADIAN) + 0.1f/c);
102
glVertex3f((rayon-b) * cos((deg+10)*RADIAN),
103
(rayon-b) * sin((deg+10)*RADIAN),
104
a * sin((deg2+amp)*RADIAN) + 0.1f/c);
110
glNormal3f (nx/n, ny/n, nz/n);
111
glVertex3f((rayon-b) * cos(deg*RADIAN),
112
(rayon-b) * sin(deg*RADIAN),
113
-a * sin((deg2+amp)*RADIAN) - 0.1f/c);
114
glVertex3f(rayon * cos(deg*RADIAN),
115
rayon * sin(deg*RADIAN),
116
-a * sin(deg2*RADIAN) - 0.1f/c);
117
glVertex3f(rayon * cos((deg+10)*RADIAN),
118
rayon * sin((deg+10)*RADIAN),
119
-a * sin(deg2*RADIAN) - 0.1f/c);
120
glVertex3f((rayon-b) * cos((deg+10)*RADIAN),
121
(rayon-b) * sin((deg+10)*RADIAN),
122
-a * sin((deg2+amp)*RADIAN) - 0.1f/c);
129
glMatrixMode(GL_TEXTURE); // On selectionne la matrice des textures
131
glMatrixMode(GL_MODELVIEW); // On revient sur la matrice d'affichage
133
// Ici c'est pour faire le cylindre qui relie les demi spheres
134
glEnable(GL_TEXTURE_2D);
135
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Couleur a fond
136
GLfloat fMaterial[4] = {1., 1., 1., 1.};
137
//glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, fMaterial); // on definit Les proprietes materielles de l'objet.
138
g_print ("iChromeTexture : %d\n", myData.iChromeTexture);
140
/*glBindTexture(GL_TEXTURE_2D, myData.iChromeTexture);
141
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); // Ici c'est pour le type de combinaison de texturing en cas de multi
142
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE); // pas de multi je remplace donc l'ancienne texture par celle ci
144
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // ok la on selectionne le type de generation des coordonnees de la texture
145
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // Ce sera du sphere mapping pour un petit effet chrome
146
glEnable(GL_TEXTURE_GEN_S); // oui je veux une generation en S
147
glEnable(GL_TEXTURE_GEN_T); // Et en T aussi
150
glActiveTexture(GL_TEXTURE1);
151
glDisable(GL_TEXTURE_2D);
152
glDisable(GL_TEXTURE_GEN_S);
153
glDisable(GL_TEXTURE_GEN_T);
154
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.);
155
glActiveTexture(GL_TEXTURE0);
156
glDisable(GL_TEXTURE_2D);
157
glDisable(GL_TEXTURE_GEN_S);
158
glDisable(GL_TEXTURE_GEN_T);
160
glColor4f (.4, .5, .8, .7);
163
//for (iter = 0;iter < 5;iter ++)
165
for (deg = 0;deg < 360;deg += 10)
167
xab = rayon * sin((deg+10)*RADIAN) - rayon * sin(deg*RADIAN);
168
yab = rayon * cos((deg+10)*RADIAN) - rayon * cos(deg*RADIAN);
174
nx = yab*zac - zab*yac;
175
ny = zab*xac - xab*zac;
176
nz = xab*yac - yab*xac;
177
n = sqrt (nx*nx + ny*ny + nz*nz);
179
glNormal3f (nx/n, ny/n,
182
glVertex3f(rayon * sin(deg*RADIAN), rayon * cos(deg*RADIAN), 0.1f/c);
183
glVertex3f(rayon * sin((deg+10)*RADIAN), rayon * cos((deg+10)*RADIAN), 0.1f/c);
184
glVertex3f(rayon * sin((deg+10)*RADIAN), rayon * cos((deg+10)*RADIAN), -0.1f/c);
185
glVertex3f(rayon * sin(deg*RADIAN), rayon * cos(deg*RADIAN), -0.1f/c);
194
glEndList(); // Fini la display list
196
/**glDisable(GL_TEXTURE_GEN_S);
197
glDisable(GL_TEXTURE_GEN_T);
198
glDisable(GL_TEXTURE_2D); // Plus de texture merci
199
glDisable(GL_TEXTURE);*/
204
GLuint cairo_dock_load_ring_calllist (void)
206
GLuint iCallList = glGenLists (1);
207
int deg, deg2, iter, nb_iter=20;
208
float amp, rayon, c=2.;
211
amp = 90.0 / nb_iter;
214
glNewList(iCallList, GL_COMPILE); // Go pour la compilation de la display list
215
glPolygonMode (GL_FRONT, GL_FILL);
216
double a = .4/c; // applatissement;
217
double b = 1./nb_iter;
218
double xab, yab, zab, xac, yac, zac, nx, ny, nz, n;
220
glColor4f (.4, .5, .8, .7);
224
//for (iter = 0;iter < 5;iter ++)
226
for (deg = 0;deg < 360;deg += 10)
228
xab = rayon * sin((deg+10)*RADIAN) - rayon * sin(deg*RADIAN);
229
yab = rayon * cos((deg+10)*RADIAN) - rayon * cos(deg*RADIAN);
235
nx = yab*zac - zab*yac;
236
ny = zab*xac - xab*zac;
237
nz = xab*yac - yab*xac;
238
n = sqrt (nx*nx + ny*ny + nz*nz);
240
glNormal3f (nx/n, ny/n, nz/n);
242
glVertex3f(rayon * sin(deg*RADIAN), rayon * cos(deg*RADIAN), 0.1f/c);
243
glVertex3f(rayon * sin((deg+10)*RADIAN), rayon * cos((deg+10)*RADIAN), 0.1f/c);
244
glVertex3f(rayon * sin((deg+10)*RADIAN), rayon * cos((deg+10)*RADIAN), -0.1f/c);
245
glVertex3f(rayon * sin(deg*RADIAN), rayon * cos(deg*RADIAN), -0.1f/c);
254
glEndList(); // Fini la display list
259
GLuint cairo_dock_load_square_calllist (void)
261
GLuint iCallList = glGenLists (1);
262
glNewList(iCallList, GL_COMPILE); // Go pour la compilation de la display list
263
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
267
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 0.); glVertex3f(-.5, .5, 0.); // Bottom Left Of The Texture and Quad
268
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 0.); glVertex3f( .5, .5, 0.); // Bottom Right Of The Texture and Quad
269
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 1.); glVertex3f( .5, -.5, 0.); // Top Right Of The Texture and Quad
270
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 1.); glVertex3f(-.5, -.5, 0.); // Top Left Of The Texture and Quad
273
glEndList(); // Fini la display list
277
GLuint cairo_dock_load_cube_calllist (void)
279
GLuint iCallList = glGenLists (1);
280
glNewList(iCallList, GL_COMPILE); // Go pour la compilation de la display list
281
glPolygonMode (GL_FRONT, GL_FILL);
283
double a = .5 / sqrt (2);
285
// Front Face (note that the texture's corners have to match the quad's corners)
287
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 0.); glVertex3f(-a, a, a); // Bottom Left Of The Texture and Quad
288
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 0.); glVertex3f( a, a, a); // Bottom Right Of The Texture and Quad
289
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 1.); glVertex3f( a, -a, a); // Top Right Of The Texture and Quad
290
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 1.); glVertex3f(-a, -a, a); // Top Left Of The Texture and Quad
293
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 0.); glVertex3f( -a, a, -a); // Bottom Right Of The Texture and Quad
294
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 1.); glVertex3f( -a, -a, -a); // Top Right Of The Texture and Quad
295
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 1.); glVertex3f(a, -a, -a); // Top Left Of The Texture and Quad
296
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 0.); glVertex3f(a, a, -a); // Bottom Left Of The Texture and Quad
299
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 1.); glVertex3f(-a, a, a); // Top Left Of The Texture and Quad
300
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 0.); glVertex3f(-a, a, -a); // Bottom Left Of The Texture and Quad
301
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 0.); glVertex3f( a, a, -a); // Bottom Right Of The Texture and Quad
302
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 1.); glVertex3f( a, a, a); // Top Right Of The Texture and Quad
305
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 1.); glVertex3f( a, -a, -a); // Top Right Of The Texture and Quad
306
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 1.); glVertex3f(-a, -a, -a); // Top Left Of The Texture and Quad
307
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 0.); glVertex3f(-a, -a, a); // Bottom Left Of The Texture and Quad
308
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 0.); glVertex3f( a, -a, a); // Bottom Right Of The Texture and Quad
311
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 0.); glVertex3f( a, a, -a); // Bottom Right Of The Texture and Quad
312
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 1.); glVertex3f( a, -a, -a); // Top Right Of The Texture and Quad
313
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 1.); glVertex3f( a, -a, a); // Top Left Of The Texture and Quad
314
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 0.); glVertex3f( a, a, a); // Bottom Left Of The Texture and Quad
317
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 0.); glVertex3f(-a, a, -a); // Bottom Left Of The Texture and Quad
318
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 0.); glVertex3f(-a, a, a); // Bottom Right Of The Texture and Quad
319
glMultiTexCoord2f( GL_TEXTURE1_ARB,1., 1.); glVertex3f(-a, -a, a); // Top Right Of The Texture and Quad
320
glMultiTexCoord2f( GL_TEXTURE1_ARB,0., 1.); glVertex3f(-a, -a, -a); // Top Left Of The Texture and Quad
323
glEndList(); // Fini la display list
328
GLuint cd_animations_load_mesh (CDAnimationsMeshType iMeshType)
330
GLuint iCallList = 0;
333
case CD_SQUARE_MESH :
334
iCallList = cairo_dock_load_square_calllist ();
338
iCallList = cairo_dock_load_cube_calllist ();
341
case CD_CAPSULE_MESH :
342
iCallList = cairo_dock_load_capsule_calllist ();