L'exécutable

Le source: Survol.cpp

#include <windows.h>

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

static float z = -15.0F ;
static float dz = 1.0F ;

void myinit(void) {
  GLfloat specular[] = { 1.0,1.0,1.0,1.0 };
  GLfloat shinines[] = { 50.0 };
  GLfloat l_pos[] = { 1.0,1.0,1.0,0.0 };
  glClearColor(0.5,0.5,1.0,1.0) ;
  glMaterialfv(GL_FRONT,GL_SPECULAR,specular);
  glMaterialfv(GL_FRONT,GL_SHININESS,shinines);
  glLightfv(GL_LIGHT0,GL_POSITION,l_pos);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  glDepthFunc(GL_LESS);
  glEnable(GL_DEPTH_TEST);
}

void ligne(void) {
  glPushMatrix() ;
  auxSolidSphere(1.0) ;
  for ( int x = 0 ; x < 4 ; x++ ) {
    glTranslatef(5.0F,0.0F,0.0F) ;
    auxSolidSphere(1.0) ; }
  glPopMatrix() ;
}

void CALLBACK display(void) {
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glPushMatrix();
  glTranslatef(0.0F,-5.0F,z) ;
  for ( int z = 0 ; z < 20 ; z++ ) {
    glPushMatrix();
    glTranslatef(-10.0F,0.0F,-5.0F*z) ;
    ligne() ;
    glPopMatrix(); }
  glPopMatrix();
  glFlush();
  auxSwapBuffers();
}

void CALLBACK myReshape(int w,int h) {
  glViewport(0,0,w,h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glFrustum(-2.5,2.5,-2.5*(float)h/(float)w,2.5*(float)h/(float)w,3.,110.);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
}

void CALLBACK idle(void) {
  z+= dz ;
  if ( ( z == 100 ) || ( z == -15 ) )
    dz = -dz ;
  display() ;
}

void main(void) {
  auxInitDisplayMode(AUX_DOUBLE|AUX_RGB|AUX_DEPTH);
  auxInitPosition(0,0,250,250);
  auxInitWindow("Sphères blanches en survol");
  myinit();
  auxIdleFunc(idle);
  auxReshapeFunc(myReshape);
  auxMainLoop(display);
}

RETOUR