Fichier source : Animation4.cpp
/* Fonction executee lors d'un rafraichissement */
/* de la fenetre de dessin */
static void display1(void) {
glClearColor(0.25F,0.25F,0.25F,0.25F);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
gluLookAt(12.0,4.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0);
glLightfv(GL_LIGHT0,GL_POSITION,light0_position);
glLightfv(GL_LIGHT1,GL_POSITION,light1_position);
glLightfv(GL_LIGHT2,GL_POSITION,light2_position);
mobile(image*15.0F);
glTranslatef(0.0F,0.0F,-15.0F);
glRotatef(image,0.0F,1.0F,0.0F);
damier();
glPopMatrix();
glFlush();
glutSwapBuffers();
int error = glGetError();
if ( error != GL_NO_ERROR )
printf("Attention erreur %d\n",error);
}
static void display2(void) {
glClearColor(0.25F,0.25F,0.25F,0.25F);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
double angle = image*3.14159/180.0;
double dirx = -cos(angle);
double diry = -0.333;
double dirz = -sin(angle);
double ex = -15.0F*sin(angle)-12.0*dirx;
double ey = 4.0F;
double ez = 15.0F*cos(angle)-12.0*dirz;
double pvx = ex+dirx;
double pvy = ey+diry;
double pvz = ez+dirz;
gluLookAt(ex,ey,ez,pvx,pvy,pvz,0.0,1.0,0.0);
glLightfv(GL_LIGHT0,GL_POSITION,light0_position);
glLightfv(GL_LIGHT1,GL_POSITION,light1_position);
glLightfv(GL_LIGHT2,GL_POSITION,light2_position);
damier();
glRotatef(-image,0.0F,1.0F,0.0F);
glTranslatef(0.0F,0.0F,15.0F);
mobile(image*15.0F);
glPopMatrix();
glFlush();
glutSwapBuffers();
int error = glGetError();
if ( error != GL_NO_ERROR )
printf("Attention erreur %d\n",error);
}
static void display3(void) {
glClearColor(0.25F,0.25F,0.25F,0.25F);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
double angle = image*3.14159/180.0;
double dirx = -cos(angle);
double diry = -0.333;
double dirz = -sin(angle);
double ex = -15.0F*sin(angle)-12.0*dirx;
double ey = 4.0F;
double ez = 15.0F*cos(angle)-12.0*dirz;
double pvx = ex+dirx;
double pvy = ey+diry;
double pvz = ez+dirz;
gluLookAt(ex,ey,ez,pvx,pvy,pvz,0.0,1.0,0.0);
glLightfv(GL_LIGHT0,GL_POSITION,light0_position);
glLightfv(GL_LIGHT1,GL_POSITION,light1_position);
glLightfv(GL_LIGHT2,GL_POSITION,light2_position);
damier();
glRotatef(-image,0.0F,1.0F,0.0F);
glTranslatef(0.0F,0.0F,15.0F);
mobile(image*15.0F);
glPopMatrix();
glFlush();
glutSwapBuffers();
int error = glGetError();
if ( error != GL_NO_ERROR )
printf("Attention erreur %d\n",error);
}
/* Fonction executee lorsqu'aucun evenement */
/* n'est en file d'attente */
static void idle(void) {
image++;
glutPostRedisplay();
}