L'exécutable

 

Le source: Lumieres.cpp

#include "windows.h"

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>

static float anglex = 0 ;
static float angley = 0 ;
static float anglez = 0 ;

void myinit(void) {
  GLfloat mat_specular[] = { 1.0,1.0,1.0,1.0 };
  GLfloat mat_shininess[] = { 50.0 };
  GLfloat light0_couleur[] = { 1.0,0.0,0.0,1.0 };
  GLfloat light1_couleur[] = { 0.0,1.0,0.0,1.0 };
  GLfloat light2_couleur[] = { 0.0,0.0,1.0,1.0 };
  glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
  glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
  glLightfv(GL_LIGHT0,GL_DIFFUSE,light0_couleur);
  glLightfv(GL_LIGHT1,GL_DIFFUSE,light1_couleur);
  glLightfv(GL_LIGHT2,GL_DIFFUSE,light2_couleur);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  glEnable(GL_LIGHT1);
  glEnable(GL_LIGHT2);
  glDepthFunc(GL_LESS);
  glEnable(GL_DEPTH_TEST);
}

void CALLBACK display(void) {
  GLfloat light0_position[] = { 1.0,1.0,1.0,0.0 };
  GLfloat light1_position[] = { -1.0,1.0,1.0,0.0 };
  GLfloat light2_position[] = { 1.0,-1.0,1.0,0.0 };
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glPushMatrix() ;
  glRotatef(anglex,1.0F,0.0F,0.0F) ;
  glRotatef(angley,0.0F,1.0F,0.0F) ;
  glRotatef(anglez,0.0F,0.0F,1.0F) ;
  glLightfv(GL_LIGHT0,GL_POSITION,light0_position);
  glLightfv(GL_LIGHT1,GL_POSITION,light1_position);
  glLightfv(GL_LIGHT2,GL_POSITION,light2_position);
  glPopMatrix() ;
  glPushMatrix() ;
  auxSolidSphere(1.0);
  glPushMatrix() ;
  glFlush();
  auxSwapBuffers() ;
}

void CALLBACK myReshape(int w,int h) {
  glViewport(0,0,w,h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  if (w <= h) 
	  glOrtho (-1.5,1.5,-1.5*(GLfloat)h/(GLfloat)w,1.5*(GLfloat)h/(GLfloat)w,-10.0,10.0);
    else 
	  glOrtho (-1.5*(GLfloat)w/(GLfloat)h,1.5*(GLfloat)w/(GLfloat)h,-1.5,1.5,-10.0,10.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
}

void CALLBACK idle(void) {
  anglex++ ;
  angley-- ;
  anglez+=2 ;
  display() ;
}

void main(void) {
  auxInitDisplayMode(AUX_DOUBLE|AUX_RGB|AUX_DEPTH);
  auxInitPosition(0,0,300,300);
  auxInitWindow("Lumières");
  myinit();
  auxIdleFunc(idle) ;
  auxReshapeFunc(myReshape);
  auxMainLoop(display);
}
 RETOUR