L'exécutable

Temple1.gif (5936 octets) Temple1.gif (5936 octets) Temple1.gif (5936 octets)

Temple1.gif (5936 octets) Temple1.gif (5936 octets)

Le source : TD-PlacementCylindreEtCone.cpp

#include <windows.h>

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

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

static float anglex = 0.0F ;
static float h = 0.5F ;
static int scene = 1 ;

void CALLBACK display(void) {
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glPushMatrix();
  glRotatef(anglex,1.0F,0.0F,0.0F) ;
  auxWireSphere(0.1);
  if ( scene )
    auxWireCylinder(1.0,h);
    else
    auxWireCone(1.0,h);
  glPopMatrix();
  glFlush();
  auxSwapBuffers();
}

void myinit (void) {
  glClearColor(0.5F,0.5F,0.5F,0.0F);
  glColor3f(1.0F,1.0F,1.0F);
  glShadeModel(GL_SMOOTH);
  glEnable(GL_DEPTH_TEST);
}

void CALLBACK myReshape(int w, int h) {
  glViewport(0,0,w,h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(-1.5,1.5,-1.5/w*h,1.5/w*h,-3.0,3.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
}

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

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

void CALLBACK left(void) {
  h += 0.1f ;
}

void CALLBACK right(void) {
  h -= 0.1f ;
}

void CALLBACK enter(void) {
  scene = 1-scene ;
}

void main(void) {
  auxInitDisplayMode(AUX_DOUBLE|AUX_RGBA|AUX_DEPTH);
  auxInitPosition (0,0,300,300);
  auxInitWindow("Placement cylindre et cone") ;
  myinit();
  auxKeyFunc(AUX_UP,up) ;
  auxKeyFunc(AUX_DOWN,down) ;
  auxKeyFunc(AUX_LEFT,left) ;
  auxKeyFunc(AUX_RIGHT,right) ;
  auxKeyFunc(AUX_RETURN,enter) ;
  auxReshapeFunc(myReshape);
  auxMainLoop(display);
}
WB01624_.gif (281 octets) RETOUR