L'exécutable

     

     

     

     

     

     

     

 

Fichier source : LumieresEtMateriel.cpp

static const float blanc[]       = { 1.0F,1.0F,1.0F,1.0F };
static const float jaune[]       = { 1.0F,1.0F,0.0F,1.0F };
static const float cyan[]        = { 0.0F,1.0F,0.0F,1.0F };
static const float magenta[]     = { 1.0F,0.0F,1.0F,1.0F };
static const float rouge[]       = { 1.0F,0.0F,0.0F,1.0F };
static const float vert[]        = { 0.0F,1.0F,0.0F,1.0F };
static const float bleu[]        = { 0.0F,0.0F,1.0F,1.0F };
static const float noir[]        = { 0.0F,0.0F,0.0F,1.0F };
static const float grisMoyen[]   = { 0.5F,0.5F,0.5F,1.0F };

static float rxl = 0.0;
static float ryl = 0.0;
static float rzl = 0.0;

/* Scene dessinee 2                              */

static void configurationMaterielCube(void) {
  switch (question) {
    case 6 :
      glMaterialfv(GL_FRONT,GL_DIFFUSE,blanc);
      break;
    case 7 :
      glMaterialfv(GL_FRONT,GL_DIFFUSE,blanc);
      glMaterialfv(GL_FRONT,GL_SPECULAR,blanc);
      glMaterialf(GL_FRONT,GL_SHININESS,64.0F);
      break; }
}

static void scene2() {
  glPushMatrix();
  configurationMaterielCube();
  mySolidCube(7.0,n);
  glPopMatrix();
}

/* Scene dessinee 1                              */

static void configurationMaterielTore1(void) {
  switch (question) {
    case 6 :
      glMaterialfv(GL_FRONT,GL_SPECULAR,blanc);
      glMaterialf(GL_FRONT,GL_SHININESS,64.0F);
      break;
    case 7 :
      glMaterialfv(GL_FRONT,GL_DIFFUSE,noir);
      glMaterialfv(GL_FRONT,GL_SPECULAR,jaune);
      glMaterialf(GL_FRONT,GL_SHININESS,15.0F);
      break; }
}

static void configurationMaterielTore2(void) {
  switch (question) {
    case 6 :
      glMaterialfv(GL_FRONT,GL_SPECULAR,blanc);
      glMaterialf(GL_FRONT,GL_SHININESS,64.0F);
      break;
    case 7 :
      glMaterialfv(GL_FRONT,GL_DIFFUSE,jaune);
      glMaterialfv(GL_FRONT,GL_SPECULAR,rouge);
      glMaterialf(GL_FRONT,GL_SHININESS,100.0F);
      break; }
}

static void configurationMaterielTore3(void) {
  switch (question) {
    case 6 :
      glMaterialfv(GL_FRONT,GL_SPECULAR,blanc);
      glMaterialf(GL_FRONT,GL_SHININESS,64.0F);
      break;
    case 7 :
      glMaterialfv(GL_FRONT,GL_EMISSION,grisMoyen);
      glMaterialfv(GL_FRONT,GL_DIFFUSE,rouge);
      glMaterialfv(GL_FRONT,GL_SPECULAR,bleu);
      glMaterialf(GL_FRONT,GL_SHININESS,64.0F);
      break; }
}

static void scene1() {
  glPushMatrix();
  configurationMaterielTore1();
  glutSolidTorus(1.0,5.0,n1,n2);
  glRotatef(90.0F,1.0F,0.0F,0.0F);
  configurationMaterielTore2();
  glutSolidTorus(1.0,5.0,n1,n2);
  glRotatef(90.0F,0.0F,1.0F,0.0F);
  configurationMaterielTore3();
  glutSolidTorus(1.0,5.0,n1,n2);
  glPopMatrix();
}

/* Fonction de configuration de la lumiere 0     */

static void configurationLumiere0() {
  const GLfloat pos[] = { 2.0,2.0,2.0,1.0 };
  glLightfv(GL_LIGHT0,GL_POSITION,pos);
  glLightfv(GL_LIGHT0,GL_DIFFUSE,rouge);
  glLightfv(GL_LIGHT0,GL_SPECULAR,noir);
  glLightfv(GL_LIGHT0,GL_AMBIENT,noir);
  switch ( attenuation ) {
    case 1 :
      glLightf(GL_LIGHT0,GL_CONSTANT_ATTENUATION,0.0F);
      glLightf(GL_LIGHT0,GL_LINEAR_ATTENUATION,1.0F);
      glLightf(GL_LIGHT0,GL_QUADRATIC_ATTENUATION,0.0F);
      break;
    case 2 :
      glLightf(GL_LIGHT0,GL_CONSTANT_ATTENUATION,0.0F);
      glLightf(GL_LIGHT0,GL_LINEAR_ATTENUATION,0.0F);
      glLightf(GL_LIGHT0,GL_QUADRATIC_ATTENUATION,1.0F);
      break; }
  glEnable(GL_LIGHT0);
}

/* Fonction de configuration de la lumiere 1     */

static void configurationLumiere1() {
  const GLfloat pos[] = { -2.0,0.0,4.0,0.0 };
  glLightfv(GL_LIGHT1,GL_POSITION,pos);
  glLightfv(GL_LIGHT1,GL_DIFFUSE,vert);
  glLightfv(GL_LIGHT1,GL_SPECULAR,blanc);
  glLightfv(GL_LIGHT1,GL_AMBIENT,noir);
  glEnable(GL_LIGHT1);
}

/* Fonction de configuration de la lumiere 2     */

static void configurationLumiere2() {
  const GLfloat pos[] = { -2.0,-2.0, 10.0,1.0 };
  const GLfloat dir[] = {  3.0, 3.0,-10.0 };
  glLightfv(GL_LIGHT2,GL_POSITION,pos);
  glLightfv(GL_LIGHT2,GL_SPOT_DIRECTION,dir);
  glLightf(GL_LIGHT2,GL_SPOT_CUTOFF,20.0F);
  glLightfv(GL_LIGHT2,GL_DIFFUSE,bleu);
  glLightfv(GL_LIGHT2,GL_SPECULAR,jaune);
  glLightfv(GL_LIGHT2,GL_AMBIENT,noir);
  glEnable(GL_LIGHT2);
}

/* Fonction de configuration des lumieres        */

static void configurationLumieres(void) {
  glPushMatrix();
  glRotatef(rxl,1.0F,0.0F,0.0F);
  glRotatef(ryl,0.0F,1.0F,0.0F);
  glRotatef(rzl,0.0F,0.0F,1.0F);
  switch (question) {
    case 1 :
      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      break;
    case 2 :
      glEnable(GL_LIGHTING);
      configurationLumiere0();
      break;
    case 3 :
      glEnable(GL_LIGHTING);
      configurationLumiere1();
      break;
    case 4 :
      glEnable(GL_LIGHTING);
      configurationLumiere2();
      break;
    case 5 :
    case 6 :
    case 7 :
      glEnable(GL_LIGHTING);
      configurationLumiere0();
      configurationLumiere1();
      configurationLumiere2();
      break; }
  glPopMatrix();
}

RETOUR