1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| void soleil(){
float n;
float scale,color;
float numlayers;
float angle = 0.0f;
//printf("appel a soleil");
glLoadIdentity();
/*place le soleil */
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(angle, 1.2f, 0.4f, 0.7f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, IdTex[5]);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
gluSphere(sphere, 2, 32, 16);
/* configuration du blending */
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBindTexture(GL_TEXTURE_2D, IdTex[6]);
/* autorise le blending */
glEnable(GL_BLEND);
/* rien n'ecrire dans le depth buffer */
glDepthMask(GL_FALSE);
/* nombre de tour de la boucle, impt -> lent */
numlayers = 50;
for (n = 1; n < numlayers; n++)
{
/* calcul du facteur scale pour les reflets*/
scale = 1+n/numlayers;
/* calcul du pourcentage de couleur utilisé pour le blending */
color = 1.0f/n+sin(angle/10)/16;
glLoadIdentity();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(angle, 1.2f, 0.4f, 0.7f);
glScalef(scale, scale, scale);
glColor4f(color, color, color, 1.0f);
gluSphere(sphere, 2, 32, 16);
}
/* ecriture dans le depth buffer */
glDepthMask(GL_TRUE);
/* empeche de faire du blending */
glDisable(GL_BLEND);
angle = angle*0.02;
/* force opengl a finir tout ce qu'il a commence */
glFlush(); |
Partager