L'exécutable

Image050.gif (6207 octets)  Image051.gif (5353 octets)

Projections orthographique et en perspective

Image052.gif (6361 octets)  Image053.gif (5612 octets)

Image054.gif (5052 octets)  Image055.gif (3863 octets)

Image056.gif (3501 octets)

Projection en perspective avec rapprochement de la scène

Image057.gif (3164 octets)  Image058.gif (5291 octets)

Projection en perspective : très grosses déformations

Le source: Projections.cpp

#include <windows.h>

#include <stdio.h>
#include <stdlib.h>

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

static int proj = 0 ;
static int ww ;
static int hh ;
static float anglex = 0.0F ;
static float angley = 0.0F ;
static float zoomPersp = 1.0F ;
static float zoomParal = 1.0F ;
static float ouverture = 1.0F ;

void projection(void) {
  if ( proj ) {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60.0*ouverture,(double) ww/hh,0.5,200.0);
    glMatrixMode(GL_MODELVIEW);
    glTranslatef(0.0F,0.0F,-5.0F*zoomPersp); }
    else {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-2.5*zoomParal,2.5*zoomParal,-2.5*zoomParal*(double) hh/ww,2.5*zoomParal*(double) hh/ww,-25,25);
    glMatrixMode(GL_MODELVIEW);
    glTranslatef(0.0F,0.0F,-5.0F); }
}

void CALLBACK display(void) {   
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glPushMatrix();
  glColor3f(1.0F,1.0F,1.0F);
  projection();
  glPushMatrix();
  glRotatef(anglex,1.0F,0.0F,0.0F);
  glRotatef(angley,0.0F,1.0F,0.0F);
  glTranslatef(-1.0F,0.0F,0.0F) ;
  float jaune[] = { 1.0F,1.0F,0.0F };
  glMaterialfv(GL_FRONT,GL_DIFFUSE,jaune);
  auxSolidCube(2.0);
  glTranslatef(2.0F,0.0F,0.0F) ;
  float bleu[] = { 0.0F,0.0F,1.0F };
  glMaterialfv(GL_FRONT,GL_DIFFUSE,bleu);
  auxSolidSphere(1.3);
  glPopMatrix();
  glPopMatrix();
  glFlush();
  auxSwapBuffers() ;
}

void CALLBACK myinit(void) {
  glShadeModel(GL_SMOOTH);
  glDepthFunc(GL_LESS) ;
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
}

void CALLBACK myReshape(int w, int h) { 
  glViewport(0,0,w,h);
  ww = w ;
  hh = h ;
}

void CALLBACK keyo(void) { 
  ouverture *= 1.01F ;
  ouverture *= 1.01F ;
}

void CALLBACK keyO(void) {
  ouverture /= 1.01F ;
  ouverture /= 1.01F ;
}

void CALLBACK keyz(void) { 
  zoomPersp *= 1.01F ;
  zoomParal *= 1.01F ;
}

void CALLBACK keyZ(void) {
  zoomPersp /= 1.01F ;
  zoomParal /= 1.01F ;
}

void CALLBACK keyP(void) {  
  proj++;
  proj %= 2;
}

void CALLBACK keyp(void) { 
  proj++;
  proj %= 2;
}

void CALLBACK up(void) {
  anglex++ ;
}

void CALLBACK down(void) {
  anglex-- ;
}

void CALLBACK left(void) {
  angley++ ;
}

void CALLBACK right(void) {
  angley-- ;
}

void main(void) {
  auxInitDisplayMode(AUX_DOUBLE|AUX_RGBA|AUX_DEPTH);
  auxInitPosition(0,0,200,200);
  auxInitWindow("Visualisations");
  myinit();
  auxKeyFunc(AUX_O,keyO);
  auxKeyFunc(AUX_o,keyo);
  auxKeyFunc(AUX_P,keyP);
  auxKeyFunc(AUX_p,keyp);
  auxKeyFunc(AUX_Z,keyZ);
  auxKeyFunc(AUX_z,keyz);
  auxKeyFunc(AUX_UP,up) ;
  auxKeyFunc(AUX_DOWN,down) ;
  auxKeyFunc(AUX_LEFT,left) ;
  auxKeyFunc(AUX_RIGHT,right) ;
  auxReshapeFunc(myReshape);
  auxMainLoop(display);
}
WB01624_.gif (281 octets) RETOUR