L'exécutable

Lumière ponctuelle rouge Lumière directionnelle verte
Spot bleu Composition des 3 lumières
Pas d'atténuation Atténuation quadratique avec composante constante
Rotation des lumières
Matériel "par défaut" Matériel diffusant dans le blanc
Matériel diffusant dans le rouge Matériel diffusant dans le jaune
Matériel avec diffusion dans le blanc et réflexion spéculaire dans le blanc

Fichier source : LumieresMateriel.cpp
Modules utilitaires

static const float noir[] = { 0.0F,0.0F,0.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 jaune[] = { 1.0F,1.0F,0.0F,1.0F };
static const float grisClair[] = { 0.8F,0.8F,0.8F,1.0F };
static const float grisFonce[] = { 0.2F,0.2F,0.2F,1.0F };
static const float blanc[] = { 1.0F,1.0F,1.0F,1.0F };

static void lumiere0(void) {
  const GLfloat light0_position[] = { 0.0,0.0,2.5,1.0 };
  glPushMatrix();
  glRotatef(r,0.0F,1.0F,0.0F);
  glLightfv(GL_LIGHT0,GL_POSITION,light0_position);
  glPopMatrix();
  glLightfv(GL_LIGHT0,GL_DIFFUSE,rouge);
  glLightfv(GL_LIGHT0,GL_SPECULAR,blanc);
  glLightfv(GL_LIGHT0,GL_AMBIENT,noir);
  if ( a ) {
    glLightf(GL_LIGHT0,GL_CONSTANT_ATTENUATION,0.3F);
    glLightf(GL_LIGHT0,GL_LINEAR_ATTENUATION,0.0F);
    glLightf(GL_LIGHT0,GL_QUADRATIC_ATTENUATION,0.3F); }
    else {
    glLightf(GL_LIGHT0,GL_CONSTANT_ATTENUATION,1.0F);
    glLightf(GL_LIGHT0,GL_LINEAR_ATTENUATION,0.0F);
    glLightf(GL_LIGHT0,GL_QUADRATIC_ATTENUATION,0.0F); }
  glEnable(GL_LIGHT0);
}

static void lumiere1(void) {
  const GLfloat light1_position[] = { 1.0,0.0,0.0,0.0 };
  glPushMatrix();
  glRotatef(r,0.0F,1.0F,0.0F);
  glLightfv(GL_LIGHT1,GL_POSITION,light1_position);
  glPopMatrix();
  glLightfv(GL_LIGHT1,GL_DIFFUSE,vert);
  glLightfv(GL_LIGHT1,GL_SPECULAR,blanc);
  glLightfv(GL_LIGHT1,GL_AMBIENT,noir);
  glEnable(GL_LIGHT1);
}

static void lumiere2(void) {
  const GLfloat light2_position[] = { 2.0,10.0,2.0,1.0 };
  const GLfloat light2_direction[] = { -4.0,-10.0,-4.0 };
  glLightfv(GL_LIGHT2,GL_POSITION,light2_position);
  glLightfv(GL_LIGHT2,GL_SPOT_DIRECTION,light2_direction);
  glLightf(GL_LIGHT2,GL_SPOT_CUTOFF,ouv);
  glLightfv(GL_LIGHT2,GL_DIFFUSE,bleu);
  glLightfv(GL_LIGHT2,GL_SPECULAR,blanc);
  glLightfv(GL_LIGHT2,GL_AMBIENT,noir);
  glEnable(GL_LIGHT2);
}

static void materiel0(void) {
  glMaterialfv(GL_FRONT,GL_DIFFUSE,blanc);
  glMaterialfv(GL_FRONT,GL_SPECULAR,noir);
  glMaterialf(GL_FRONT,GL_SHININESS,0.0F);
  glMaterialfv(GL_FRONT,GL_AMBIENT,noir);
  glMaterialfv(GL_FRONT,GL_EMISSION,noir);
}

static void materiel1(void) {
  glMaterialfv(GL_FRONT,GL_DIFFUSE,rouge);
  glMaterialfv(GL_FRONT,GL_SPECULAR,noir);
  glMaterialf(GL_FRONT,GL_SHININESS,0.0F);
  glMaterialfv(GL_FRONT,GL_AMBIENT,noir);
  glMaterialfv(GL_FRONT,GL_EMISSION,noir);
}

static void materiel2(void) {
  glMaterialfv(GL_FRONT,GL_DIFFUSE,jaune);
  glMaterialfv(GL_FRONT,GL_SPECULAR,noir);
  glMaterialf(GL_FRONT,GL_SHININESS,0.0F);
  glMaterialfv(GL_FRONT,GL_AMBIENT,noir);
  glMaterialfv(GL_FRONT,GL_EMISSION,noir);
}

static void materiel3(void) {
  glMaterialfv(GL_FRONT,GL_DIFFUSE,blanc);
  glMaterialfv(GL_FRONT,GL_SPECULAR,blanc);
  glMaterialf(GL_FRONT,GL_SHININESS,shn);
  glMaterialfv(GL_FRONT,GL_AMBIENT,noir);
  glMaterialfv(GL_FRONT,GL_EMISSION,noir);
}

static void materielBase(void) {
  glMaterialfv(GL_FRONT,GL_DIFFUSE,grisClair);
  glMaterialfv(GL_FRONT,GL_SPECULAR,noir);
  glMaterialf(GL_FRONT,GL_SHININESS,0.0);
  glMaterialfv(GL_FRONT,GL_AMBIENT,grisFonce);
  glMaterialfv(GL_FRONT,GL_EMISSION,noir);
}

RETOUR